00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 #ifdef GIDS
00033 
00034 
00035 #include <sys/types.h>
00036 #include <stdlib.h>
00037 #include <ctype.h>
00038 
00039 #include "rules.h"
00040 #include "decode.h"
00041 #include "plugbase.h"
00042 #include "parser.h"
00043 #include "debug.h"
00044 #include "util.h"
00045 #include "mstring.h"
00046 #include "plugin_enum.h"
00047 #include "spp_stickydrop.h"
00048 #include "sp_stickydrop.h"
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 void StickyDSpInit(char *, OptTreeNode *, int);
00064 static void StickyDSpRuleParseFunction(char *, OptTreeNode *, StickyDSp *);
00065 static int StickyDSpFunction(Packet *, struct _OptTreeNode *, 
00066         OptFpList *);
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 void SetupStickyDSp()
00082 {
00083     
00084     RegisterPlugin("sticky-drop", StickyDSpInit);
00085 
00086     DEBUG_WRAP(DebugMessage(DEBUG_PLUGIN,"Plugin: StickyDSp Setup\n"););
00087 }
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 void StickyDSpInit(char *data, OptTreeNode *otn, int protocol)
00105 {
00106     StickyDSp *stickydsp_d;
00107     OptFpList *ofl;
00108 
00109     if(!SppStickydIsRunning())
00110     {
00111         FatalError("dude, you can't have a sticky-drop plugin without the sticky-drop preproc\n");
00112     }
00113     stickydsp_d = (StickyDSp *) SnortAlloc(sizeof(StickyDSp));
00114     StickyDSpRuleParseFunction(data, otn, stickydsp_d);
00115 
00116     ofl = AddOptFuncToList(StickyDSpFunction, otn);
00117     ofl->context = (void *) stickydsp_d;
00118     otn->ds_list[PLUGIN_STICKYDSP]=(StickyDSp *)stickydsp_d;
00119 }
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 static void StickyDSpRuleParseFunction(char *data, OptTreeNode *otn, StickyDSp *sd) 
00138 {
00139    char **toks;
00140    int numToks;
00141    char *direction;
00142    toks = mSplit(data, ",", 2, &numToks, 0);
00143 
00144       if(numToks > 2)
00145          FatalError("ERROR %s (%d): Bad arguments to sticky-drop: %s\n", file_name,
00146                  file_line, data);
00147   
00148            if(isdigit((char)toks[0][1]))
00149            {
00150                sd->stickyd_timeout = atoi(toks[0]);
00151            }
00152            else
00153            {
00154                FatalError("ERROR %s (%d): Bad arguments to sticky-drop: %s\n", file_name,
00155                      file_line, data);
00156            }
00157 
00158         
00159       if(numToks > 1)
00160       {
00161           direction = toks[1];
00162 
00163           while(isspace((int)*direction)) {direction++;}
00164 
00165           if(!strcasecmp(direction, "src"))
00166           {           
00167               sd->stickyd_direction = 0;
00168           }         
00169           else if(!strcasecmp(direction, "dst"))
00170           {                
00171               sd->stickyd_direction = 1;
00172           }
00173           else
00174           {
00175    
00176                FatalError("%s(%d):we need a direction either src or dst%s\n",file_name,file_line,toks[1]);
00177           }
00178       }
00179 
00180        mSplitFree(&toks, numToks);
00181 }
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 static int StickyDSpFunction(Packet *p, struct _OptTreeNode *otn, OptFpList *fp_list)
00200 {
00201 
00202 
00203 
00204 
00205 
00206     return 1;
00207 }
00208 
00209 
00210 #endif