00001
00002
00006
00007
00008 #include "../../main/protoplug.h"
00009 #include "../../main/types.h"
00010 #include "../../main/policy.h"
00011 #include "../../main/memory.h"
00012
00013 #ifndef DEBUG_ETHERNET
00014 #ifdef DEBUG
00015 #define DEBUG_ETHERNET DEBUG
00016 #else
00017 #define DEBUG_ETHERNET 0
00018 #endif
00019 #endif
00020
00022 int (*Decode)(PACKET*, PROTO);
00023
00024 PROTOPLUG *pp = (PROTOPLUG*)0;
00025
00026
00039
00040 int pluginRegister(INPLUG **inp, ANPLUG **anp, PROTOPLUG **protop, OUTPLUG **outp,
00041 int(*DecodeCallback)(PACKET*,PROTO)){
00042 if(DEBUG_ETHERNET>=DEBUG_DO_ENTRY_ALL){
00043 printf("Enter pluginRegister(inp(%lx),anp(%lx),protop(%lx),outp(%lx),DecodeCallback(%lx))\n", inp, anp, protop, outp, DecodeCallback);
00044 }
00045
00046 Decode = DecodeCallback;
00047 *inp = (INPLUG*)0;
00048 *anp = (ANPLUG*)0;
00049 *outp = (OUTPLUG*)0;
00050
00051
00052 if(!pp){
00053 (*protop) = (PROTOPLUG*)malloc_safe(sizeof(PROTOPLUG));
00054 if(!(*protop)){
00055 printf("ERR: Malloc failed when registering ethernet plugin\n");
00056 }
00057 else {
00058 (*protop)->name = strdup(PROTO_ETH_NAME);
00059 (*protop)->nProto = 1;
00060 (*protop)->version = 0x00010000;
00061 (*protop)->pProto = (PROTO*)malloc_safe(sizeof(PROTO));
00062 (*protop)->sProto = (char**)malloc_safe(sizeof(char*));
00063 if(!((*protop)->name) || !((*protop)->pProto) || !((*protop)->sProto)){
00064 printf("ERR: Malloc failed when registering ethernet plugin\n");
00065 (*protop) = (PROTOPLUG*)0;
00066 }
00067 else {
00068 ((*protop)->pProto)[0] = PROTO_ETH_NUM;
00069 ((*protop)->sProto)[0] = strdup_safe(PROTO_ETH_NAME);
00070 }
00071 }
00072 pp = *protop;
00073 }
00074 else *protop = pp;
00075
00076 return 0;
00077 }
00078
00079
00084
00085 int pluginInit(int ct, char **inits){
00086 if(DEBUG_ETHERNET>=DEBUG_DO_ENTRY_ALL){
00087 printf("Enter pluginInit(int ct(%d),char**inits(%lx))\n", ct, inits);
00088 }
00089 return 0;
00090 }
00091
00092
00101
00102 int pluginCleanup(int reason){
00103 if(DEBUG_ETHERNET>=DEBUG_DO_ENTRY_ALL){
00104 printf("Enter pluginCleanup(int reason(%d))\n", reason);
00105 }
00106
00107 if(pp) free_safe(pp);
00108 pp = (PROTOPLUG*)0;
00109
00110 return 0;
00111 }
00112
00113
00125
00126 int pluginDecode(PACKET *p, PROTO protocol){
00127 if(DEBUG_ETHERNET>=DEBUG_DO_ENTRY_SOME){
00128 printf("Enter pluginDecode(PACKET*p(%lx),PROTO protocol(%lx))\n", p, protocol);
00129 }
00130 return 0;
00131 }
00132
00133
00144
00145 int pluginTest(PACKET *p, char *arg, char *val){
00146 if(DEBUG_ETHERNET>=DEBUG_DO_ENTRY_ALL){
00147 printf("Enter pluginTest(PACKET*p(%lx),char*arg(%s), char*val(%s))\n", p, arg, val);
00148 }
00149 return 0;
00150 }
00151
00152
00166
00167 int pluginPrint(PACKET *p, char *args,
00168 int(*print)(char *fmt, ...)){
00169 if(DEBUG_ETHERNET>=DEBUG_DO_ENTRY_ALL){
00170 printf("Enter pluginPrint(PACKET*p(%lx),char*args(%s),print(%lx))\n", p, args, print);
00171 }
00172 return 0;
00173 }
00174
00175
00189
00190 int pluginMkTest(PROTO p, char *val, char *test, char *field, POLICY_TEST *pTest){
00191 if(DEBUG_ETHERNET>=DEBUG_DO_ENTRY_ALL){
00192 printf("Enter pluginMkTest(PROTO p(%lx),char*val(%s),char*test(%s),char*field(%s),POLICY_TEST*pTest(%lx))\n", p, val, test, field, pTest);
00193 }
00194
00195 return 0;
00196 }