added unknown udp....
This commit is contained in:
@@ -155,70 +155,61 @@ void Connection::add(Packet *packet) {
|
||||
Connection *findConnectionWithMatchingSource(Packet *packet, short int packettype) {
|
||||
assert(packet->Outgoing());
|
||||
|
||||
ConnList *current = NULL;
|
||||
switch(packettype)
|
||||
{
|
||||
case IPPROTO_TCP:
|
||||
{ //std::cout<<"hell.......o"<<std::endl;
|
||||
ConnList *current = connections;
|
||||
while (current != NULL) {
|
||||
/* the reference packet is always outgoing */
|
||||
if (packet->matchSource(current->getVal()->refpacket)) {
|
||||
return current->getVal();
|
||||
}
|
||||
|
||||
current = current->getNext();
|
||||
}
|
||||
return NULL;
|
||||
{
|
||||
current = connections;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case IPPROTO_UDP:
|
||||
{
|
||||
ConnList *current = unknownudp->connections;
|
||||
while (current != NULL) {
|
||||
/* the reference packet is always outgoing */
|
||||
if (packet->matchSource(current->getVal()->refpacket)) {
|
||||
return current->getVal();
|
||||
}
|
||||
|
||||
current = current->getNext();
|
||||
}
|
||||
return NULL;
|
||||
current = unknownudp->connections;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
while (current != NULL) {
|
||||
/* the reference packet is always outgoing */
|
||||
if (packet->matchSource(current->getVal()->refpacket)) {
|
||||
return current->getVal();
|
||||
}
|
||||
|
||||
current = current->getNext();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
Connection *findConnectionWithMatchingRefpacketOrSource(Packet *packet, short int packettype) {
|
||||
|
||||
ConnList *current = NULL;
|
||||
switch(packettype)
|
||||
{
|
||||
case IPPROTO_TCP:
|
||||
{ ConnList *current = connections;
|
||||
while (current != NULL) {
|
||||
/* the reference packet is always *outgoing* */
|
||||
if (packet->match(current->getVal()->refpacket)) {
|
||||
return current->getVal();
|
||||
}
|
||||
|
||||
current = current->getNext();
|
||||
}
|
||||
{
|
||||
current = connections;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case IPPROTO_UDP:
|
||||
{ ConnList *current = unknownudp->connections;
|
||||
while (current != NULL) {
|
||||
/* the reference packet is always *outgoing* */
|
||||
if (packet->match(current->getVal()->refpacket)) {
|
||||
return current->getVal();
|
||||
}
|
||||
{
|
||||
current = unknownudp->connections;
|
||||
break;
|
||||
|
||||
current = current->getNext();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while (current != NULL) {
|
||||
/* the reference packet is always *outgoing* */
|
||||
if (packet->match(current->getVal()->refpacket)) {
|
||||
return current->getVal();
|
||||
}
|
||||
current = current->getNext();
|
||||
}
|
||||
|
||||
return findConnectionWithMatchingSource(packet, packettype);
|
||||
|
||||
@@ -141,8 +141,6 @@ void dp_parse_tcp(struct dp_handle *handle, const dp_header *header,
|
||||
|
||||
void dp_parse_udp(struct dp_handle *handle, const dp_header *header,
|
||||
const u_char *packet) {
|
||||
// const struct tcphdr * tcp = (struct tcphdr *) packet;
|
||||
// u_char * payload = (u_char *) packet + sizeof (struct tcphdr);
|
||||
|
||||
if (handle->callback[dp_packet_udp] != NULL) {
|
||||
int done =
|
||||
@@ -174,7 +172,6 @@ void dp_parse_ip(struct dp_handle *handle, const dp_header *header,
|
||||
case IPPROTO_UDP:
|
||||
if(catchall)
|
||||
dp_parse_udp(handle, header, payload);
|
||||
//fprintf(stdout, "udp packet...................\n");
|
||||
break;
|
||||
default:
|
||||
// TODO: maybe support for non-tcp IP packets
|
||||
@@ -200,7 +197,6 @@ void dp_parse_ip6(struct dp_handle *handle, const dp_header *header,
|
||||
case IPPROTO_UDP:
|
||||
if(catchall)
|
||||
dp_parse_udp(handle, header, payload);
|
||||
//fprintf(stdout, "udp packet...................\n");
|
||||
break;
|
||||
default:
|
||||
// TODO: maybe support for non-tcp ipv6 packets
|
||||
@@ -219,7 +215,6 @@ void dp_parse_ethernet(struct dp_handle *handle, const dp_header *header,
|
||||
int done = (handle->callback[dp_packet_ethernet])(handle->userdata, header,
|
||||
packet);
|
||||
|
||||
|
||||
/* return if handle decides we're done */
|
||||
if (done)
|
||||
return;
|
||||
|
||||
@@ -27,7 +27,7 @@ static void help(bool iserror) {
|
||||
// output << "usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [-f (eth|ppp))]
|
||||
// [device [device [device ...]]]\n";
|
||||
output << "usage: nethogs [-V] [-h] [-b] [-d seconds] [-v mode] [-c count] "
|
||||
"[-t] [-p] [-s] [-a] [-l] [-f filter] [-C catchall]"
|
||||
"[-t] [-p] [-s] [-a] [-l] [-f filter] [-C]"
|
||||
"[device [device [device ...]]]\n";
|
||||
output << " -V : prints version.\n";
|
||||
output << " -h : prints this help.\n";
|
||||
@@ -44,7 +44,8 @@ static void help(bool iserror) {
|
||||
output << " -s : sort output by sent column.\n";
|
||||
output << " -l : display command line.\n";
|
||||
output << " -a : monitor all devices, even loopback/stopped ones.\n";
|
||||
output << " -f : EXPERIMENTAL: specify string pcap filter (like tcpdump)."
|
||||
output << " -C : capture TCP and UDP.\n";
|
||||
output << " -f : EXPRIMENTAL: specify string pcap filter (like tcpdump)."
|
||||
" This may be removed or changed in a future version.\n";
|
||||
output << " device : device(s) to monitor. default is all "
|
||||
"interfaces up and running excluding loopback\n";
|
||||
@@ -54,7 +55,6 @@ static void help(bool iserror) {
|
||||
output << " s: sort by SENT traffic\n";
|
||||
output << " r: sort by RECEIVE traffic\n";
|
||||
output << " l: display command line\n";
|
||||
output << " C: capture all packets\n";
|
||||
output << " m: switch between total (KB, B, MB) and KB/s mode\n";
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ void clean_up() {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
process_init();
|
||||
|
||||
int promisc = 0;
|
||||
bool all = false;
|
||||
|
||||
Reference in New Issue
Block a user