00001 #include "route_arp.h"
00002 #include <string.h>
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include "../packets/packet.h"
00006 #include "../engine/num_list.h"
00007 #include "../decoders/decode_arp.h"
00008 #include <arpa/inet.h>
00009 #include <netinet/in.h>
00010
00011 int ARPDecoderID;
00012
00013
00014
00015 extern GlobalVars Globals;
00016
00017
00018
00019
00020 int RouteARP(int PacketSlot){
00021 PacketRec* p;
00022 ARPData* Arp;
00023
00024 #ifdef DEBUGPATH
00025 printf("In RouteARP\n");
00026 #endif
00027
00028 p=&Globals.Packets[PacketSlot];
00029
00030 if (!GetDataByID(PacketSlot, ARPDecoderID, (void**)&Arp)){
00031 #ifdef DEBUG
00032 printf("This isn't an ARP packet\n");
00033 #endif
00034 return ROUTE_RESULT_CONTINUE;
00035 }
00036
00037 #ifdef DEBUG
00038 printf("Routing an ARP packet\n");
00039 #endif
00040
00041 if (
00042 (ntohs(Arp->Header->Operation)==ARP_OP_REQUEST) ||
00043 (ntohs(Arp->Header->Operation)==ARP_OP_REPLY)
00044 ){
00045
00046 #ifdef DEBUG
00047 printf("ARP:Setting packet to broacast\n");
00048 #endif
00049 Globals.Packets[PacketSlot].TargetInterface=INTERFACE_BROADCAST;
00050 return ROUTE_RESULT_DONE;
00051 }
00052
00053 #ifdef DEBUG
00054 printf("Wasn't a known ARP type %04X\n",ntohs(Arp->Header->Operation));
00055 #endif
00056
00057 return ROUTE_RESULT_CONTINUE;
00058 }
00059
00060
00061
00062
00063 int RouteARPAddNode(int RouteID, char* Args){
00064 #ifdef DEBUGPATH
00065 printf("In RouteARPAddNode\n");
00066 #endif
00067
00068 return TRUE;
00069 }
00070
00071
00072
00073
00074
00075 int InitRouteARP(){
00076 int RouteID;
00077 #ifdef DEBUGPATH
00078 printf("In InitARP\n");
00079 #endif
00080
00081 if ( (RouteID=CreateRoute("ARP"))==ROUTE_NONE){
00082 printf("Couldn't create route ARP\n");
00083 return FALSE;
00084 }
00085
00086 Globals.Routes[RouteID].RouteFunc=RouteARP;
00087 Globals.Routes[RouteID].AddNode=RouteARPAddNode;
00088
00089 return TRUE;
00090 }
00091