Commit dee85e94 authored by 's avatar
Browse files

Fixed PoS


git-svn-id: file:///home/svn/mapi/trunk@1435 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent add33d00
...@@ -10,6 +10,7 @@ typedef struct eflow_data { ...@@ -10,6 +10,7 @@ typedef struct eflow_data {
u_char ptcl; u_char ptcl;
u_char ttl_pkt1; u_char ttl_pkt1;
unsigned long long epoch; unsigned long long epoch;
unsigned int valid;
} eflow_data; } eflow_data;
typedef struct flow_data { typedef struct flow_data {
......
...@@ -317,7 +317,7 @@ void poll_expired_flows(mapidflib_function_instance_t *instance) { ...@@ -317,7 +317,7 @@ void poll_expired_flows(mapidflib_function_instance_t *instance) {
tmp->previous->next = tmp->next; tmp->previous->next = tmp->next;
// if packets_count is worth to add // if packets_count is worth to add
if(tmp->flow.packets_count >= ((struct exfl_data *)instance->internal_data)->packets_count_min) { if(tmp->flow.valid && tmp->flow.packets_count >= ((struct exfl_data *)instance->internal_data)->packets_count_min) {
if(data->expired_flows_list_size < data->expired_flows_list_size_max) { // if buffer not full if(data->expired_flows_list_size < data->expired_flows_list_size_max) { // if buffer not full
//add node to expired flows list //add node to expired flows list
data->expired_flows_list_size++; data->expired_flows_list_size++;
...@@ -346,7 +346,7 @@ void poll_expired_flows(mapidflib_function_instance_t *instance) { ...@@ -346,7 +346,7 @@ void poll_expired_flows(mapidflib_function_instance_t *instance) {
} }
else { // shm not full else { // shm not full
// if packets_count is worth to add // if packets_count is worth to add
if(tmp->flow.packets_count >= ((struct exfl_data *)instance->internal_data)->packets_count_min) { if(tmp->flow.valid && tmp->flow.packets_count >= ((struct exfl_data *)instance->internal_data)->packets_count_min) {
// Add the expired flow from temporal sorted list directly into shared memory table // Add the expired flow from temporal sorted list directly into shared memory table
pthread_mutex_lock( shm_struct.smmutex ); pthread_mutex_lock( shm_struct.smmutex );
memcpy(&(shm_struct.Table[*(shm_struct.size)]), &(tmp->flow), sizeof(struct flow_data)); memcpy(&(shm_struct.Table[*(shm_struct.size)]), &(tmp->flow), sizeof(struct flow_data));
...@@ -384,6 +384,9 @@ static int exprflow_instance(mapidflib_function_instance_t *instance, ...@@ -384,6 +384,9 @@ static int exprflow_instance(mapidflib_function_instance_t *instance,
instance->def->shm_size = sizeof(flows_stat) + sizeof(struct flow_data) * shm_flows + sizeof(pthread_mutex_t); instance->def->shm_size = sizeof(flows_stat) + sizeof(struct flow_data) * shm_flows + sizeof(pthread_mutex_t);
// 0 shm (instance->result.data) DIMAPI_DATA_SIZE
// | mapi_result_type | flows_stat | shm_flows * flow_data | pthread_mutex_t |
return 0; return 0;
} }
...@@ -503,7 +506,7 @@ static int exprflow_process(mapidflib_function_instance_t *instance, MAPI_UNUSED ...@@ -503,7 +506,7 @@ static int exprflow_process(mapidflib_function_instance_t *instance, MAPI_UNUSED
p += sizeof(struct hdlc_header); p += sizeof(struct hdlc_header);
len -= sizeof(struct hdlc_header); len -= sizeof(struct hdlc_header);
ethertype = ntohs(hp->ctrl); ethertype = ntohs(hp->proto);
if (ethertype != ETHERTYPE_IP) { if (ethertype != ETHERTYPE_IP) {
return 0; return 0;
...@@ -527,6 +530,7 @@ static int exprflow_process(mapidflib_function_instance_t *instance, MAPI_UNUSED ...@@ -527,6 +530,7 @@ static int exprflow_process(mapidflib_function_instance_t *instance, MAPI_UNUSED
record.dport = ntohs(tcp->dport); record.dport = ntohs(tcp->dport);
record.timestamp = pkt_head->ts; record.timestamp = pkt_head->ts;
record.epoch = data->epoch; record.epoch = data->epoch;
record.valid = data->epoch > TIMEOUT;
record.ptcl = ip->ptcl; record.ptcl = ip->ptcl;
record.bytes_count = pkt_head->wlen - headerlenoverplus; record.bytes_count = pkt_head->wlen - headerlenoverplus;
record.ttl_pkt1 = ip->ttl; record.ttl_pkt1 = ip->ttl;
...@@ -541,6 +545,7 @@ static int exprflow_process(mapidflib_function_instance_t *instance, MAPI_UNUSED ...@@ -541,6 +545,7 @@ static int exprflow_process(mapidflib_function_instance_t *instance, MAPI_UNUSED
record.dport = ntohs(udp->dport); record.dport = ntohs(udp->dport);
record.timestamp = pkt_head->ts; record.timestamp = pkt_head->ts;
record.epoch = data->epoch; record.epoch = data->epoch;
record.valid = data->epoch > TIMEOUT;
record.ptcl = ip->ptcl; record.ptcl = ip->ptcl;
record.bytes_count = pkt_head->wlen - headerlenoverplus; record.bytes_count = pkt_head->wlen - headerlenoverplus;
record.ttl_pkt1 = ip->ttl; record.ttl_pkt1 = ip->ttl;
...@@ -553,6 +558,7 @@ static int exprflow_process(mapidflib_function_instance_t *instance, MAPI_UNUSED ...@@ -553,6 +558,7 @@ static int exprflow_process(mapidflib_function_instance_t *instance, MAPI_UNUSED
record.sport = record.dport = ntohs(0); record.sport = record.dport = ntohs(0);
record.timestamp = pkt_head->ts; record.timestamp = pkt_head->ts;
record.epoch = data->epoch; record.epoch = data->epoch;
record.valid = data->epoch > TIMEOUT;
record.ptcl = ip->ptcl; record.ptcl = ip->ptcl;
record.bytes_count = pkt_head->wlen - headerlenoverplus; record.bytes_count = pkt_head->wlen - headerlenoverplus;
record.ttl_pkt1 = ip->ttl; record.ttl_pkt1 = ip->ttl;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment