Compare commits
4
Commits
2.0
...
2.0-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6607c33cb8 | ||
|
|
de8e469c09 | ||
|
|
3cfcc05912 | ||
|
|
cf1402d64e |
@@ -1865,8 +1865,7 @@ static void pcap_process_packet(u_char *args,
|
|||||||
trailer->master_protocol = htons(p.master_protocol), trailer->app_protocol = htons(p.app_protocol);
|
trailer->master_protocol = htons(p.master_protocol), trailer->app_protocol = htons(p.app_protocol);
|
||||||
ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct, p, trailer->name, sizeof(trailer->name));
|
ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct, p, trailer->name, sizeof(trailer->name));
|
||||||
crc = (uint32_t*)&extcap_buf[h.caplen+sizeof(struct ndpi_packet_trailer)];
|
crc = (uint32_t*)&extcap_buf[h.caplen+sizeof(struct ndpi_packet_trailer)];
|
||||||
*crc = 0;
|
*crc = ethernet_crc32((const void*)extcap_buf, h.caplen+sizeof(struct ndpi_packet_trailer));
|
||||||
ethernet_crc32((const void*)extcap_buf, h.caplen+sizeof(struct ndpi_packet_trailer), crc);
|
|
||||||
h.caplen += delta, h.len += delta;
|
h.caplen += delta, h.len += delta;
|
||||||
|
|
||||||
#ifdef DEBUG_TRACE
|
#ifdef DEBUG_TRACE
|
||||||
|
|||||||
+10
-7
@@ -885,9 +885,8 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
|
|||||||
|
|
||||||
static uint32_t crc32_for_byte(uint32_t r) {
|
static uint32_t crc32_for_byte(uint32_t r) {
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for(j = 0; j < 8; ++j)
|
for(j = 0; j < 8; ++j)
|
||||||
r = ((r & 1) ? 0 : ((uint32_t)0xEDB88320L) ^ r >> 1);
|
r = (r & 1? 0: (uint32_t)0xEDB88320L) ^ r >> 1;
|
||||||
return r ^ (uint32_t)0xFF000000L;
|
return r ^ (uint32_t)0xFF000000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -897,8 +896,7 @@ static uint32_t crc32_for_byte(uint32_t r) {
|
|||||||
typedef unsigned long accum_t;
|
typedef unsigned long accum_t;
|
||||||
|
|
||||||
static void init_tables(uint32_t* table, uint32_t* wtable) {
|
static void init_tables(uint32_t* table, uint32_t* wtable) {
|
||||||
size_t i, k, w, j;
|
size_t i, j, k, w;
|
||||||
|
|
||||||
for(i = 0; i < 0x100; ++i)
|
for(i = 0; i < 0x100; ++i)
|
||||||
table[i] = crc32_for_byte(i);
|
table[i] = crc32_for_byte(i);
|
||||||
for(k = 0; k < sizeof(accum_t); ++k)
|
for(k = 0; k < sizeof(accum_t); ++k)
|
||||||
@@ -909,11 +907,10 @@ static void init_tables(uint32_t* table, uint32_t* wtable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ethernet_crc32(const void* data, size_t n_bytes, uint32_t* crc) {
|
static void __crc32(const void* data, size_t n_bytes, uint32_t* crc) {
|
||||||
static uint32_t table[0x100], wtable[0x100*sizeof(accum_t)];
|
static uint32_t table[0x100], wtable[0x100*sizeof(accum_t)];
|
||||||
size_t n_accum = n_bytes/sizeof(accum_t);
|
size_t n_accum = n_bytes/sizeof(accum_t);
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
|
|
||||||
if(!*table)
|
if(!*table)
|
||||||
init_tables(table, wtable);
|
init_tables(table, wtable);
|
||||||
for(i = 0; i < n_accum; ++i) {
|
for(i = 0; i < n_accum; ++i) {
|
||||||
@@ -921,7 +918,13 @@ void ethernet_crc32(const void* data, size_t n_bytes, uint32_t* crc) {
|
|||||||
for(j = *crc = 0; j < sizeof(accum_t); ++j)
|
for(j = *crc = 0; j < sizeof(accum_t); ++j)
|
||||||
*crc ^= wtable[(j << 8) + (uint8_t)(a >> 8*j)];
|
*crc ^= wtable[(j << 8) + (uint8_t)(a >> 8*j)];
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = n_accum*sizeof(accum_t); i < n_bytes; ++i)
|
for(i = n_accum*sizeof(accum_t); i < n_bytes; ++i)
|
||||||
*crc = table[(uint8_t)*crc ^ ((uint8_t*)data)[i]] ^ *crc >> 8;
|
*crc = table[(uint8_t)*crc ^ ((uint8_t*)data)[i]] ^ *crc >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u_int32_t ethernet_crc32(const void* data, size_t n_bytes) {
|
||||||
|
u_int32_t crc = 0;
|
||||||
|
__crc32(data, n_bytes, &crc);
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -165,6 +165,6 @@ static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow *
|
|||||||
/* compare two nodes in workflow */
|
/* compare two nodes in workflow */
|
||||||
int ndpi_workflow_node_cmp(const void *a, const void *b);
|
int ndpi_workflow_node_cmp(const void *a, const void *b);
|
||||||
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow);
|
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow);
|
||||||
void ethernet_crc32(const void* data, size_t n_bytes, uint32_t* crc);
|
u_int32_t ethernet_crc32(const void* data, size_t n_bytes);
|
||||||
void ndpi_flow_info_freer(void *node);
|
void ndpi_flow_info_freer(void *node);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -3753,7 +3753,7 @@ void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struc
|
|||||||
packet->line[packet->parsed_lines].ptr = packet->payload;
|
packet->line[packet->parsed_lines].ptr = packet->payload;
|
||||||
packet->line[packet->parsed_lines].len = 0;
|
packet->line[packet->parsed_lines].len = 0;
|
||||||
|
|
||||||
for(a = 0; a < end-1 /* This because get_u_int16_t(packet->payload, a) reads 2 bytes */; a++) {
|
for(a = 0; a <= end-1 /* This because get_u_int16_t(packet->payload, a) reads 2 bytes */; a++) {
|
||||||
if(get_u_int16_t(packet->payload, a) == ntohs(0x0d0a)) {
|
if(get_u_int16_t(packet->payload, a) == ntohs(0x0d0a)) {
|
||||||
packet->line[packet->parsed_lines].len = (u_int16_t)(((unsigned long) &packet->payload[a]) - ((unsigned long) packet->line[packet->parsed_lines].ptr));
|
packet->line[packet->parsed_lines].len = (u_int16_t)(((unsigned long) &packet->payload[a]) - ((unsigned long) packet->line[packet->parsed_lines].ptr));
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,16 @@ function slen(str)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- the dissector function callback
|
-- the dissector function callback
|
||||||
|
local num_pkts = 0
|
||||||
|
|
||||||
function ndpi_proto.dissector(tvb, pinfo, tree)
|
function ndpi_proto.dissector(tvb, pinfo, tree)
|
||||||
|
num_pkts = num_pkts + 1
|
||||||
|
|
||||||
|
-- Wireshark dissects the packet twice. We ignore the first
|
||||||
|
-- run as on that step the packet is still undecoded
|
||||||
|
-- The trick below avoids to process the packet twice
|
||||||
|
if(num_pkts < pinfo.number) then return end
|
||||||
|
|
||||||
local pktlen = tvb:len()
|
local pktlen = tvb:len()
|
||||||
local eth_trailer = f_eth_trailer()
|
local eth_trailer = f_eth_trailer()
|
||||||
local magic = tostring(tvb(pktlen-28,4))
|
local magic = tostring(tvb(pktlen-28,4))
|
||||||
|
|||||||
Reference in New Issue
Block a user