#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
+#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
static bool parse_flowstats(DAQ_MsgType type, const char* line, HextMsgDesc *desc)
{
-#define FLOWSTATS_FORMAT "%d %d %d %d %s %hu %s %hu %u %lu %lu %lu %lu %lu %lu %hhu %ld %ld %hu %hu %hhu"
+#define FLOWSTATS_FORMAT \
+ "%" SCNi32 " " /* ingressZone */ \
+ "%" SCNi32 " " /* egressZone */ \
+ "%" SCNi32 " " /* ingressIntf */ \
+ "%" SCNi32 " " /* egressIntf */ \
+ "%s " /* srcAddr */ \
+ "%" SCNu16 " " /* initiatorPort */ \
+ "%s " /* dstAddr */ \
+ "%" SCNu16 " " /* responderPort */ \
+ "%" SCNu32 " " /* opaque */ \
+ "%" SCNu64 " " /* initiatorPkts */ \
+ "%" SCNu64 " " /* responderPkts */ \
+ "%" SCNu64 " " /* initiatorPktsDropped */ \
+ "%" SCNu64 " " /* responderPktsDropped */ \
+ "%" SCNu64 " " /* initiatorBytesDropped */ \
+ "%" SCNu64 " " /* responderBytesDropped */ \
+ "%" SCNu8 " " /* isQoSAppliedOnSrcIntf */ \
+ "%" SCNu32 " " /* sof_timestamp.tv_sec */ \
+ "%" SCNu32 " " /* eof_timestamp.tv_sec */ \
+ "%" SCNu16 " " /* vlan_tag */ \
+ "%" SCNu16 " " /* address_space_id */ \
+ "%" SCNu8 /* protocol */
#define FLOWSTATS_ITEMS 21
Flow_Stats_t* f = &desc->flowstats;
char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN];
+ uint32_t sof_sec, eof_sec;
int rval = sscanf(line, FLOWSTATS_FORMAT, &f->ingressZone, &f->egressZone, &f->ingressIntf,
&f->egressIntf, srcaddr, &f->initiatorPort, dstaddr, &f->responderPort, &f->opaque,
&f->initiatorPkts, &f->responderPkts, &f->initiatorPktsDropped, &f->responderPktsDropped,
&f->initiatorBytesDropped, &f->responderBytesDropped, &f->isQoSAppliedOnSrcIntf,
- &f->sof_timestamp.tv_sec, &f->eof_timestamp.tv_sec, &f->vlan_tag, &f->address_space_id,
+ &sof_sec, &eof_sec, &f->vlan_tag, &f->address_space_id,
&f->protocol);
if (rval != FLOWSTATS_ITEMS)
return false;
+ f->sof_timestamp.tv_sec = sof_sec;
+ f->eof_timestamp.tv_sec = eof_sec;
+
desc->msg.type = type;
desc->msg.hdr_len = sizeof(desc->flowstats);
desc->msg.hdr = &desc->flowstats;
{
if ( v.is("page") )
return getpage(v.get_string());
- else
- return false;
return true;
}
case icmp::IcmpType::ADDRESSREPLY:
TextLog_Print(log, "ID: %u Seq: %u ADDRESS REPLY: 0x%08X",
ntohs(icmph->s_icmp_id), ntohs(icmph->s_icmp_seq),
- (u_int)ntohl(icmph->s_icmp_mask));
+ ntohl(icmph->s_icmp_mask));
break;
default:
}
}
- if ( (u_int)(p->pkth->ts.tv_sec) > last_prune_time + TAG_PRUNE_QUANTUM )
+ if ( (unsigned)(p->pkth->ts.tv_sec) > last_prune_time + TAG_PRUNE_QUANTUM )
{
PruneTagCache(p->pkth->ts.tv_sec, 0);
last_prune_time = p->pkth->ts.tv_sec;
struct timeval now;
packet_gettimeofday(&now);
- struct timeval time_to_add = { timeout, 0 };
+ struct timeval time_to_add = { static_cast<time_t>(timeout), 0 };
timeradd(&now, &time_to_add, &new_node.cache_expire_time);
new_node.file = new FileContext;
}
struct timeval next_expire_time;
- struct timeval time_to_add = { timeout, 0 };
+ struct timeval time_to_add = { static_cast<time_t>(timeout), 0 };
timeradd(&now, &time_to_add, &next_expire_time);
// Refresh the timer on the cache.
if (!timerisset(&file_ctx->pending_expire_time))
{
- add_time = { lookup_timeout, 0 };
+ add_time = { static_cast<time_t>(lookup_timeout), 0 };
timeradd(&now, &add_time, &file_ctx->pending_expire_time);
if (PacketTracer::is_active())
{
size_t len = strlen(str);
if (fd >= 0)
- write(fd, str, len);
+ (void) write(fd, str, len);
else if (buf)
{
if (len > buf_size - buf_idx - 1)
** tag numbers, etc.
**
** @param ASN1_DATA ptr to data
-** @param u_int ptr to tag num
+** @param unsigned ptr to tag num
**
** @return integer
**
** @retval ASN1_ERR_OOB encoding goes out of bounds
** @retval ASN1_ERR_NULL_MEM function arguments are NULL
*/
-static int asn1_decode_tag_num_ext(ASN1_DATA* asn1_data, u_int* tag_num)
+static int asn1_decode_tag_num_ext(ASN1_DATA* asn1_data, unsigned* tag_num)
{
int iExtension = 0;
- u_int new_tag_num;
+ unsigned new_tag_num;
if (!asn1_data || !tag_num)
return ASN1_ERR_NULL_MEM;
** @retval ASN1_ERR_OOB out of bounds condition
** @retval ASN1_OK function successful
*/
-static int asn1_decode_len_ext(ASN1_DATA* asn1_data, u_int* size)
+static int asn1_decode_len_ext(ASN1_DATA* asn1_data, unsigned* size)
{
int iBytes;
int iCtr;
- u_int new_size;
+ unsigned new_size;
if (!asn1_data || !size)
return ASN1_ERR_NULL_MEM;
** @retval ASN1_ERR_INVALID_ARG invalid argument
** @retval ASN1_ERR_OOB out of bounds
*/
-static int asn1_decode_type(const uint8_t** data, u_int* len, ASN1_TYPE** asn1_type)
+static int asn1_decode_type(const uint8_t** data, unsigned* len, ASN1_TYPE** asn1_type)
{
ASN1_DATA asn1data;
- u_int uiRawLen;
+ unsigned uiRawLen;
int iRet;
if (!*data)
** @retval ASN1_OK function successful
** @retval !ASN1_OK lots of error conditions, figure it out
*/
-int asn1_decode(const uint8_t* data, u_int len, ASN1_TYPE** asn1_type)
+int asn1_decode(const uint8_t* data, unsigned len, ASN1_TYPE** asn1_type)
{
ASN1_TYPE* cur;
ASN1_TYPE* child = nullptr;
ASN1_TYPE* asnstack[ASN1_MAX_STACK];
const uint8_t* end;
- u_int con_len;
+ unsigned con_len;
int index = 0;
int iRet;
case ICMP_ADDRESSREPLY:
TextLog_Print(log, "ID: %u Seq: %u ADDRESS REPLY: 0x%08X",
ntohs(p->ptrs.icmph->s_icmp_id), ntohs(p->ptrs.icmph->s_icmp_seq),
- (u_int)ntohl(p->ptrs.icmph->s_icmp_mask));
+ ntohl(p->ptrs.icmph->s_icmp_mask));
break;
default:
RetryQueue(unsigned interval_ms)
{
assert(interval_ms > 0);
- interval = { interval_ms / 1000, static_cast<suseconds_t>((interval_ms % 1000) * 1000) };
+ interval = { static_cast<time_t>(interval_ms / 1000), static_cast<suseconds_t>((interval_ms % 1000) * 1000) };
}
~RetryQueue()
struct timeval now, increment;
unsigned int timeout = SnortConfig::get_conf()->daq_config->timeout;
packet_gettimeofday(&now);
- increment = { timeout / 1000, static_cast<suseconds_t>((timeout % 1000) * 1000) };
+ increment = { static_cast<time_t>(timeout / 1000), static_cast<suseconds_t>((timeout % 1000) * 1000) };
timeradd(&now, &increment, &now);
packet_time_update(&now);
uint32_t first_decrypted_packet_debug = 0;
#endif
bool log_stats = false;
- unsigned long app_stats_period = 300;
- unsigned long app_stats_rollover_size = 0;
+ uint32_t app_stats_period = 300;
+ uint32_t app_stats_rollover_size = 0;
const char* app_detector_dir = nullptr;
std::string tp_appid_path = "";
std::string tp_appid_config = "";
va_list ap;
va_start(ap, format);
- s_pkt_trace->log(format, ap);
+ s_pkt_trace->log_va(format, ap);
va_end(ap);
}
va_list ap;
va_start(ap, format);
- s_pkt_trace->log(format, ap);
+ s_pkt_trace->log_va(format, ap);
va_end(ap);
s_pkt_trace->mutes[mute] = true;
}
}
-void PacketTracer::log(const char* format, va_list ap)
+void PacketTracer::log_va(const char* format, va_list ap)
{
// FIXIT-L Need to find way to add 'PktTracerDbg' string as part of format string.
std::string dbg_str;
template<typename T = PacketTracer> static void _thread_init();
// non-static functions
- void log(const char*, va_list);
+ void log_va(const char*, va_list);
void add_ip_header_info(const snort::Packet&);
void add_eth_header_info(const snort::Packet&);
void add_packet_type_info(const snort::Packet&);
using namespace HttpCommon;
using namespace Http2Enums;
+#ifdef REG_TEST
static void print_flow_issues(FILE*, Http2Infractions* const, Http2EventGen* const);
+#endif
Http2Inspect::Http2Inspect(const Http2ParaList* params_) : params(params_)
{
stream->clear_frame();
}
+#ifdef REG_TEST
static void print_flow_issues(FILE* output, Http2Infractions* const infractions,
Http2EventGen* const events)
{
fprintf(output, "Infractions: %016" PRIx64 ", Events: %016" PRIx64 "\n\n",
infractions->get_raw(), events->get_raw());
}
+#endif
"%02d/%02d/%02d-%02d:%02d:%02d.%06u",
year, lt->tm_mon + 1, lt->tm_mday,
s / 3600, (s % 3600) / 60, s % 60,
- (u_int)tvp->tv_usec);
+ (unsigned)tvp->tv_usec);
}
else
{
(void)SnortSnprintf(timebuf, TIMEBUF_SIZE,
"%02d/%02d-%02d:%02d:%02d.%06u", lt->tm_mon + 1,
lt->tm_mday, s / 3600, (s % 3600) / 60, s % 60,
- (u_int)tvp->tv_usec);
+ (unsigned)tvp->tv_usec);
}
}