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 #include "arp-tracer.h"
00031 #include <sap.h>
00032 #include <address.h>
00033 #include <mac.h>
00034 #include <mac-802_11.h>
00035
00036
00037
00038 ARP_Tracer::ARP_Tracer() : Tracer(5) {}
00039
00040 void ARP_Tracer::format(Packet *p, SAP *sap)
00041 {
00042 hdr_cmn *ch = hdr_cmn::access(p);
00043 if(ch->ptype() != PT_ARP)
00044 return;
00045
00046 struct hdr_arp *ah = HDR_ARP(p);
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 switch (ah->arp_op)
00058 {
00059 case ARPOP_REQUEST:
00060 writeTrace(sap, " -- ARP -- [Who has %d.%d.%d.%d? Tell %d.%d.%d.%d at %02x:%02x:%02x:%02x]",
00061 (ah->arp_tpa & 0xff000000)>>24,
00062 (ah->arp_tpa & 0x00ff0000)>>16,
00063 (ah->arp_tpa & 0x0000ff00)>>8,
00064 (ah->arp_tpa & 0x000000ff),
00065 (ah->arp_spa & 0xff000000)>>24,
00066 (ah->arp_spa & 0x00ff0000)>>16,
00067 (ah->arp_spa & 0x0000ff00)>>8,
00068 (ah->arp_spa & 0x000000ff),
00069 (ah->arp_sha & 0xff000000)>>24,
00070 (ah->arp_sha & 0x00ff0000)>>16,
00071 (ah->arp_sha & 0x0000ff00)>>8,
00072 (ah->arp_sha & 0x000000ff)
00073 );
00074 break;
00075
00076 case ARPOP_REPLY:
00077 writeTrace(sap, " -- ARP -- [%d.%d.%d.%d is at %02x:%02x:%02x:%02x]",
00078 (ah->arp_spa & 0xff000000)>>24,
00079 (ah->arp_spa & 0x00ff0000)>>16,
00080 (ah->arp_spa & 0x0000ff00)>>8,
00081 (ah->arp_spa & 0x000000ff),
00082 (ah->arp_sha & 0xff000000)>>24,
00083 (ah->arp_sha & 0x00ff0000)>>16,
00084 (ah->arp_sha & 0x0000ff00)>>8,
00085 (ah->arp_sha & 0x000000ff)
00086 );
00087 break;
00088
00089 case ARPOP_REVREQUEST:
00090 writeTrace(sap, " -- ARP -- [REVREQUEST]");
00091 break;
00092
00093 case ARPOP_REVREPLY:
00094 writeTrace(sap, " -- ARP -- [REVREPLY]");
00095 break;
00096
00097 case ARPOP_INVREQUEST:
00098 writeTrace(sap, " -- ARP -- [INVREQUEST]");
00099 break;
00100
00101
00102 case ARPOP_INVREPLY:
00103 writeTrace(sap, " -- ARP -- [INVREPLY]");
00104 break;
00105 }
00106
00107 }
00108
00109
00110 extern "C" int Arptracer_Init()
00111 {
00112
00113
00114
00115
00116
00117
00118 SAP::addTracer(new ARP_Tracer);
00119 return 0;
00120 }
00121 extern "C" int Cygarptracer_Init()
00122 {
00123 Arptracer_Init();
00124 }
00125
00126