< >cannot be resolved!!

yador
22 de Junio del 2008
Hola a todos,

Vereis estoy desarrollando un pequeño(o no tan pequeño) sniffer de paquetes.Parece que tengo problemas con los import,lo cual es una tonteria,por lo menos a priori,pero me estoy rompiendo la cabeza por que creo que tengo todos los import bien.

La output del compilador me genera errores en varios .java fuentes del mismo tipo de error(cannot be resolved).

Posteo este codigo para que lo podais examinar.

**************************************************************
//PATH:sniffer/JDPacketAnalyzerLoader.java

package sniffer;
import java.util.*;

import sniffer.analyzer.*;

public class JDPacketAnalyzerLoader
{
static Vector analyzers=new Vector();

static void loadDefaultAnalyzer(){
analyzers.addElement(new PacketAnalyzer());
analyzers.addElement(new EthernetAnalyzer());
analyzers.addElement(new IPv4Analyzer());
analyzers.addElement(new IPv6Analyzer());
analyzers.addElement(new TCPAnalyzer());
analyzers.addElement(new UDPAnalyzer());
analyzers.addElement(new ICMPAnalyzer());
analyzers.addElement(new HTTPAnalyzer());
analyzers.addElement(new FTPAnalyzer());
analyzers.addElement(new TelnetAnalyzer());
analyzers.addElement(new SSHAnalyzer());
analyzers.addElement(new SMTPAnalyzer());
analyzers.addElement(new POP3Analyzer());
analyzers.addElement(new ARPAnalyzer());
}

public static JDPacketAnalyzer[] getAnalyzers(){
JDPacketAnalyzer[] array=new JDPacketAnalyzer[analyzers.size()];

for(int i=0;i<array.length;i++)
array[i]=(JDPacketAnalyzer)analyzers.elementAt(i);

return array;
}

public static JDPacketAnalyzer[] getAnalyzersOf(int layer){
Vector v=new Vector();

for(int i=0;i<analyzers.size();i++)
if(((JDPacketAnalyzer)analyzers.elementAt(i)).layer==layer)
v.addElement(analyzers.elementAt(i));

JDPacketAnalyzer[] res=new JDPacketAnalyzer[v.size()];
for(int i=0;i<res.length;i++)
res[i]=(JDPacketAnalyzer)v.elementAt(i);

return res;
}
}

// 0 ERRORES///////

*************************************************************
//PATH:/sniffer/stat/sniffer/stat/NetworkProtocolStat.java

//Si,el path es asi de raro.Lo genero eclipse

package sniffer.stat;
import java.util.Vector;

import jpcap.Packet;
import sniffer.JDPacketAnalyzerLoader;//1º ERROR
import sniffer.analyzer.JDPacketAnalyzer;
//import sniffer.analyzer.JDPacketAnalyzerLoader;
public class NetworkProtocolStat extends JDStatisticsTaker
{
JDPacketAnalyzer[] analyzers;
long[] numOfPs;
long totalPs;
long[] sizeOfPs;
long totalSize;
String[] labels;
static final String[] types={"# of packets","% of packets","total packet size","% of size"};

public NetworkProtocolStat(){
analyzers=JDPacketAnalyzerLoader.getAnalyzersOf(JDPacketAnalyzer.NETWORK_LAYER);//2ª ERROR
numOfPs=new long[analyzers.length+1];
sizeOfPs=new long[analyzers.length+1];

labels=new String[analyzers.length+1];
for(int i=0;i<analyzers.length;i++)
labels[i]=analyzers[i].getProtocolName();
labels[analyzers.length]="Other";
}

public String getName(){
return "Netowrk Layer Protocol Ratio";
}

public void analyze(Vector packets){
for(int i=0;i<packets.size();i++){
Packet p=(Packet)packets.elementAt(i);
totalPs++;
totalSize+=p.len;

boolean flag=false;
for(int j=0;j<analyzers.length;j++)
if(analyzers[j].isAnalyzable(p)){
numOfPs[j]++;
totalPs++;
sizeOfPs[j]+=p.len;
flag=true;
break;
}
if(!flag){
numOfPs[numOfPs.length-1]++;
sizeOfPs[sizeOfPs.length-1]+=p.len;
}
}
}

public void addPacket(Packet p){
boolean flag=false;
totalPs++;
totalSize+=p.len;
for(int j=0;j<analyzers.length;j++)
if(analyzers[j].isAnalyzable(p)){
numOfPs[j]++;
sizeOfPs[j]+=p.len;
flag=true;
break;
}
if(!flag){
numOfPs[numOfPs.length-1]++;
sizeOfPs[sizeOfPs.length-1]+=p.len;
}
}

public String[] getLabels(){
return labels;
}

public String[] getStatTypes(){
return types;
}

public long[] getValues(int index){
switch(index){
case 0: //# of packets
if(numOfPs==null) return new long[0];
return numOfPs;
case 1: //% of packets
long[] percents=new long[numOfPs.length];
if(totalPs==0) return percents;
for(int i=0;i<numOfPs.length;i++)
percents[i]=numOfPs[i]*100/totalPs;
return percents;
case 2: //total packet size
if(sizeOfPs==null) return new long[0];
return sizeOfPs;
case 3: //% of size
long[] percents2=new long[sizeOfPs.length];
if(totalSize==0) return percents2;
for(int i=0;i<sizeOfPs.length;i++)
percents2[i]=sizeOfPs[i]*100/totalSize;
return percents2;
default:
return null;
}
}
/*
String[] getTableLabels(){
String[] ls=new String[labels.length+1];
ls[0]=new String();
System.arraycopy(labels,0,ls,1,labels.length);

return ls;
}

Object[][] getTableValues(){
if(numOfPs==null) return new Object[0][0];
long sum=0;
Object[][] obj=new Object[4][labels.length+1];

obj[0][0]="# of packets";
for(int i=0;i<numOfPs.length;i++){
obj[0][i+1]=new Long(numOfPs[i]);
sum+=numOfPs[i];
}

obj[1][0]="% of packet #";
for(int i=0;i<numOfPs.length;i++){
if(sum==0) obj[1][i+1]=new Integer(0);
else obj[1][i+1]=new Integer(numOfPs[i]*100/(int)sum);
}

sum=0;
obj[2][0]="size of packets";
for(int i=0;i<sizeOfPs.length;i++){
obj[2][i+1]=new Long(sizeOfPs[i]);
sum+=sizeOfPs[i];
}

obj[3][0]="% of size";
for(int i=0;i<sizeOfPs.length;i++){
if(sum==0) obj[3][i+1]=new Long(0);
else obj[3][i+1]=new Long(sizeOfPs[i]*100/sum);
}

return obj;
}
*/

public void clear(){
numOfPs=new long[analyzers.length+1];
sizeOfPs=new long[analyzers.length+1];
totalPs=0;
totalSize=0;
}
}
End Of File
**************************************************************


Que decis?Muchisimas gracias de antemano,aunque solo sea por leer todo este cacho de texto

sonnykwe
22 de Junio del 2008
Hola, intento crear un sniffer en Java para redes inalámbricas podrías por favor guiarme con documentación, sitios o alguna otra cosa que me pueda ayudar, gracias.