00001
00002
00003
00004
00005 #include "route_broadcast.h"
00006 #include <string.h>
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include "../packets/packet.h"
00010 #include "../engine/num_list.h"
00011 #include "../decoders/decode.h"
00012 #include "../decoders/decode_ethernet.h"
00013 #include <arpa/inet.h>
00014
00015 int EthernetDecoderID;
00016
00017
00018
00019
00020 extern GlobalVars Globals;
00021
00022
00023
00024
00025 int RouteBroadcast(int PacketSlot){
00026 EthernetData* EData;
00027 PacketRec* p;
00028
00029 #ifdef DEBUGPATH
00030 printf("In RouteBroadcast\n");
00031 #endif
00032
00033 p=&Globals.Packets[PacketSlot];
00034
00035 if (!GetDataByID(p->PacketSlot, EthernetDecoderID, (void**)&EData)){
00036 #ifdef DEBUG
00037 printf("This isn't an ethernet packet\n");
00038 #endif
00039 return ROUTE_RESULT_CONTINUE;
00040 }
00041
00042 #ifdef DEBUG
00043 printf("Checking Ethernet Broadcast %02X:%02X:%02X:%02X:%02X:%02X->%02X:%02X:%02X:%02X:%02X:%02X\n",
00044 EData->Header->SrcMac[0],
00045 EData->Header->SrcMac[1],
00046 EData->Header->SrcMac[2],
00047 EData->Header->SrcMac[3],
00048 EData->Header->SrcMac[4],
00049 EData->Header->SrcMac[5],
00050
00051 EData->Header->DstMac[0],
00052 EData->Header->DstMac[1],
00053 EData->Header->DstMac[2],
00054 EData->Header->DstMac[3],
00055 EData->Header->DstMac[4],
00056 EData->Header->DstMac[5]);
00057 #endif
00058
00059 if (
00060 (EData->Header->DstMac[0]==0xFF) &&
00061 (EData->Header->DstMac[1]==0xFF) &&
00062 (EData->Header->DstMac[2]==0xFF) &&
00063 (EData->Header->DstMac[3]==0xFF) &&
00064 (EData->Header->DstMac[4]==0xFF) &&
00065 (EData->Header->DstMac[5]==0xFF)
00066 ){
00067 #ifdef DEBUG
00068 printf("This is an ethernet broadcast\n");
00069 #endif
00070 p->TargetInterface=INTERFACE_BROADCAST;
00071 return ROUTE_RESULT_DONE;
00072 }
00073
00074
00075 #ifdef DEBUG
00076 printf("There isn't a route set for this packet\n");
00077 #endif
00078 return ROUTE_RESULT_CONTINUE;
00079 }
00080
00081
00082
00083
00084 int RouteBroadcastAddNode(int RouteID, char* Args){
00085 #ifdef DEBUGPATH
00086 printf("In RouteBroadcastAddNode\n");
00087 #endif
00088
00089 #ifdef DEBUG
00090 printf("Adding with args %s\n",Args);
00091 #endif
00092
00093 return TRUE;
00094 }
00095
00096
00097
00098
00099 int InitRouteBroadcast(){
00100 int RouteID;
00101
00102 #ifdef DEBUGPATH
00103 printf("In InitRoutBroadcast\n");
00104 #endif
00105
00106 if ( (RouteID=CreateRoute("Broadcast"))==ROUTE_NONE){
00107 printf("Couldn't create route Broadcast\n");
00108 return FALSE;
00109 }
00110
00111 Globals.Routes[RouteID].RouteFunc=RouteBroadcast;
00112 Globals.Routes[RouteID].AddNode=RouteBroadcastAddNode;
00113
00114 if ( (EthernetDecoderID=GetDecoderByName("Ethernet"))==DECODER_NONE){
00115 printf("Couldn't find the Ethernet Decoder\n");
00116 return FALSE;
00117 }
00118
00119 return TRUE;
00120 }
00121