Commit b088f49b authored by Stig Venaas's avatar Stig Venaas
Browse files

changed shift so move in front of all elements smaller than us, and fixed so...

changed shift so move in front of all elements smaller than us, and fixed so check if protocol different from what we are looking for

git-svn-id: file:///home/svn/mapi/trunk@802 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 4b19ed44
......@@ -88,12 +88,6 @@ void extract_field(unsigned int link_type, struct topx_field *field, unsigned ch
ip = (ip_header*)(dev_pkt + ether_len);
ip_len = (ip->ver_ihl & 0xf) * 4;
if(ip->ptcl != IPPROTO_TCP && ip->ptcl != IPPROTO_UDP) { // no TCP packet
field->len=0;
return;
}
field->needs_reverse=0;
switch(protocol) {
......@@ -138,6 +132,10 @@ void extract_field(unsigned int link_type, struct topx_field *field, unsigned ch
}
break;
case TOPX_TCP:
if (ip->ptcl != IPPROTO_TCP) { // no TCP packet
field->len=0;
return;
}
tcp = (tcp_header*)(dev_pkt + ether_len + ip_len);
//tcp_len = tcp->off * 4;
switch(pfield) {
......@@ -178,6 +176,10 @@ void extract_field(unsigned int link_type, struct topx_field *field, unsigned ch
}
break;
case TOPX_UDP:
if (ip->ptcl != IPPROTO_UDP) { // no UDP packet
field->len=0;
return;
}
udp = (udp_header *)(dev_pkt + ether_len + ip_len);
switch(pfield) {
case TOPX_UDP_SRCPORT:
......@@ -219,36 +221,33 @@ struct topx_hash_node *hash_lookup(unsigned int value,struct topx_data *data) {
}
void check_for_shift(struct topx_data *data,struct topx_list_node *node) {
struct topx_list_node *previous;
struct topx_list_node *before;
if(data->sortby==SORT_BY_PACKETS) {
if((!(node->previous)) || (node->previous->count > node->count))
return;
}
else {
if((!(node->previous)) || (node->previous->bytecount > node->bytecount))
return;
}
previous=node->previous;
//delete node from its current place
previous->next=node->next;
if(node->next)
node->next->previous=previous;
else {
data->list_tail=previous;
}
before = node;
if (data->sortby == SORT_BY_PACKETS)
for (; before->previous && before->previous->count < node->count; before = before->previous);
else
for (; before->previous && before->previous->bytecount < node->bytecount; before = before->previous);
if (before == node)
return;
node->next=previous;
if(previous->previous)
previous->previous->next=node;
/* delete node from its current place */
node->previous->next = node->next;
if (node->next)
node->next->previous = node->previous;
else
data->list_tail = node->previous;
/* insert in front of before */
node->next = before;
if (before->previous)
before->previous->next = node;
else
data->list_head=node;
node->previous=previous->previous;
previous->previous=node;
data->list_head = node;
node->previous = before->previous;
before->previous = node;
}
void add_to_hashtable_and_list(struct topx_data *data,unsigned int value,unsigned long long bytes, unsigned int last_rst) {
......
Markdown is supported
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