Merge pull request #81 from tumi8/fix_remaining_warnings
solved the additional clang warningsmaster
commit
329e904d46
|
@ -523,7 +523,7 @@ 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 %d NetflowV9 messages from %s detected (SN=%u, expected=%u).",
|
||||
msg(MSG_INFO, "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) {
|
||||
|
@ -620,7 +620,7 @@ 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 %d IPFIX Data Records from %s detected (SN=%u, expected=%u).",
|
||||
msg(MSG_INFO, "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) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
/**
|
||||
* print functions which have formerly been in IpfixParser.cpp
|
||||
|
@ -587,7 +588,7 @@ void IpfixPrinter::printOneLineRecord(IpfixDataRecord* record)
|
|||
if (fi != NULL && fi->type.length==2) {
|
||||
srcport = ntohs(*reinterpret_cast<uint16_t*>(record->data+fi->offset));
|
||||
}
|
||||
snprintf(buf, ARRAY_SIZE(buf), "%hhu.%hhu.%hhu.%hhu:%hu", (srcip>>0)&0xFF, (srcip>>8)&0xFF, (srcip>>16)&0xFF, (srcip>>24)&0xFF, srcport);
|
||||
snprintf(buf, ARRAY_SIZE(buf), "%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 ":%" PRIu16, (uint8_t)((srcip>>0)&0xFF), (uint8_t)((srcip>>8)&0xFF), (uint8_t)((srcip>>16)&0xFF), (uint8_t)((srcip>>24)&0xFF), srcport);
|
||||
fprintf(fh, "%21s ", buf);
|
||||
|
||||
fi = dataTemplateInfo->getFieldInfo(IPFIX_TYPEID_destinationIPv4Address, 0);
|
||||
|
@ -600,7 +601,7 @@ void IpfixPrinter::printOneLineRecord(IpfixDataRecord* record)
|
|||
if (fi != NULL && fi->type.length==2) {
|
||||
dstport = ntohs(*reinterpret_cast<uint16_t*>(record->data+fi->offset));
|
||||
}
|
||||
snprintf(buf, ARRAY_SIZE(buf), "%hhu.%hhu.%hhu.%hhu:%hu", (dstip>>0)&0xFF, (dstip>>8)&0xFF, (dstip>>16)&0xFF, (dstip>>24)&0xFF, dstport);
|
||||
snprintf(buf, ARRAY_SIZE(buf), "%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 ":%" PRIu16, (uint8_t)((dstip>>0)&0xFF), (uint8_t)((dstip>>8)&0xFF), (uint8_t)((dstip>>16)&0xFF), (uint8_t)((dstip>>24)&0xFF), dstport);
|
||||
fprintf(fh, "%21s ", buf);
|
||||
|
||||
fi = dataTemplateInfo->getFieldInfo(IPFIX_TYPEID_packetDeltaCount, 0);
|
||||
|
|
|
@ -71,59 +71,13 @@ static char buf[1024];
|
|||
* unreliable, because it doesn't return an error code when it is
|
||||
* used with a kernel that doesn't support the ELF note. On some other
|
||||
* architectures there may be a system call or sysctl() that will work.
|
||||
*
|
||||
* A more recent update: kernels older than 2.4+ are no longer supported
|
||||
* by vermont.
|
||||
*/
|
||||
|
||||
unsigned long long Hertz;
|
||||
|
||||
static void old_Hertz_hack(void){
|
||||
unsigned long long user_j, nice_j, sys_j, other_j; /* jiffies (clock ticks) */
|
||||
double up_1, up_2, seconds;
|
||||
unsigned long long jiffies;
|
||||
unsigned h;
|
||||
char* savelocale;
|
||||
|
||||
savelocale = setlocale(LC_NUMERIC, NULL);
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
do{
|
||||
FILE_TO_BUF(UPTIME_FILE,uptime_fd); sscanf(buf, "%lf", &up_1);
|
||||
/* uptime(&up_1, NULL); */
|
||||
FILE_TO_BUF(STAT_FILE,stat_fd);
|
||||
sscanf(buf, "cpu %Lu %Lu %Lu %Lu", &user_j, &nice_j, &sys_j, &other_j);
|
||||
FILE_TO_BUF(UPTIME_FILE,uptime_fd); sscanf(buf, "%lf", &up_2);
|
||||
/* uptime(&up_2, NULL); */
|
||||
} while((long long)( (up_2-up_1)*1000.0/up_1 )); /* want under 0.1% error */
|
||||
setlocale(LC_NUMERIC, savelocale);
|
||||
jiffies = user_j + nice_j + sys_j + other_j;
|
||||
seconds = (up_1 + up_2) / 2;
|
||||
h = (unsigned)( (double)jiffies/seconds/smp_num_cpus );
|
||||
/* actual values used by 2.4 kernels: 32 64 100 128 1000 1024 1200 */
|
||||
switch(h){
|
||||
case 9 ... 11 : Hertz = 10; break; /* S/390 (sometimes) */
|
||||
case 18 ... 22 : Hertz = 20; break; /* user-mode Linux */
|
||||
case 30 ... 34 : Hertz = 32; break; /* ia64 emulator */
|
||||
case 48 ... 52 : Hertz = 50; break;
|
||||
case 58 ... 61 : Hertz = 60; break;
|
||||
case 62 ... 65 : Hertz = 64; break; /* StrongARM /Shark */
|
||||
case 95 ... 105 : Hertz = 100; break; /* normal Linux */
|
||||
case 124 ... 132 : Hertz = 128; break; /* MIPS, ARM */
|
||||
case 195 ... 204 : Hertz = 200; break; /* normal << 1 */
|
||||
case 253 ... 260 : Hertz = 256; break;
|
||||
case 393 ... 408 : Hertz = 400; break; /* normal << 2 */
|
||||
case 790 ... 808 : Hertz = 800; break; /* normal << 3 */
|
||||
case 990 ... 1010 : Hertz = 1000; break; /* ARM */
|
||||
case 1015 ... 1035 : Hertz = 1024; break; /* Alpha, ia64 */
|
||||
case 1180 ... 1220 : Hertz = 1200; break; /* Alpha */
|
||||
default:
|
||||
#ifdef HZ
|
||||
Hertz = (unsigned long long)HZ; /* <asm/param.h> */
|
||||
#else
|
||||
/* If 32-bit or big-endian (not Alpha or ia64), assume HZ is 100. */
|
||||
Hertz = (sizeof(long)==sizeof(int) || htons(999)==999) ? 100UL : 1024UL;
|
||||
#endif
|
||||
fprintf(stderr, "Unknown HZ value! (%d) Assume %Ld.\n", h, Hertz);
|
||||
}
|
||||
}
|
||||
|
||||
#define NOTE_NOT_FOUND 42
|
||||
|
||||
//extern char** environ;
|
||||
|
@ -158,7 +112,11 @@ static void init_libproc(void){
|
|||
if(Hertz!=NOTE_NOT_FOUND) return;
|
||||
fputs("2.4+ kernel w/o ELF notes? -- report this\n", stderr);
|
||||
}
|
||||
old_Hertz_hack();
|
||||
else{
|
||||
fputs("Kernels older than 2.4+ are no longer supported\n", stderr);
|
||||
}
|
||||
// the kernel is too old or it has no ELF notes
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <vector>
|
||||
|
||||
|
||||
#define ERROR(...) vermont_exception(__LINE__, __FILE__, __PRETTY_FUNCTION__, __func__, ##__VA_ARGS__)
|
||||
#define ERROR(...) vermont_exception(__LINE__, __FILE__, __PRETTY_FUNCTION__, __func__, __VA_ARGS__)
|
||||
|
||||
// redefine assert, so that ASSERT is always properly defined in unit tests
|
||||
#undef ASSERT
|
||||
|
|
Loading…
Reference in New Issue