00001 
00002 
00003 #ifdef HAVE_CONFIG_H
00004 #include "config.h"
00005 #endif
00006 
00007 #include <stdio.h>
00008 #include <time.h>
00009 
00010 
00011 #include "packet_time.h"
00012 
00013 #include "flow_callback.h"
00014 #include "flow_cache.h"
00015 
00016 
00017 #include "flow_stat.h"
00018 
00019 
00020 #include "portscan/flowps_snort.h"
00021 
00022 static int s_debug = 0;
00023 
00024 int flow_callbacks(FLOW_POSITION position, FLOW *flowp, int direction, Packet *p)
00025 {
00026     time_t now;
00027     
00028     if(flowp == NULL)
00029     {
00030         return FLOW_ENULL;
00031     }
00032 
00033     if(position < FLOW_NEW || position >= FLOW_MAX)
00034     {
00035         return FLOW_EINVALID;
00036     }
00037 
00038     if(s_debug > 5)
00039     {
00040 #ifndef WIN32
00041         flow_printf("DEBUG: %s called at postition %s on flow: %p ",__func__,
00042                flowcache_pname(position), flowp);
00043 #else
00044         flow_printf("DEBUG: %s(%d) called at postition %s on flow: %p ",__FILE__,__LINE__,
00045                flowcache_pname(position), flowp);
00046 #endif
00047         flowkey_print(&flowp->key);
00048         flow_printf("\n");
00049     }
00050 
00051        
00052     now = packet_timeofday();
00053     
00054     switch(position)
00055     {
00056     case FLOW_NEW:
00057         flowps_newflow_callback(position, flowp, direction, now ,p);        
00058         flowstat_callback(position, flowp, direction, now, p);
00059         break;
00060     case FLOW_ADDITIONAL:
00061         flowstat_callback(position, flowp, direction, now, p);
00062         break;
00063     case FLOW_FIRST_BIDIRECTIONAL:
00064         
00065 
00066 
00067         break;        
00068     case FLOW_SHUTDOWN:
00069         flowstat_callback(position, flowp, direction, now, p);
00070         break;
00071     default:
00072         flow_printf("Unknown position: %d\n", position);
00073         return 1;
00074     }
00075     
00076     return FLOW_SUCCESS;
00077 }
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093     
00094 
00095