I have been trying to develop an application to stop packets from reaching a particular IP address. However I am getting the following 2 errors:
1) Multiple markers at this line
- The left-hand side of an assignment must be a
variable - Syntax error on token ".0", invalid AssignmentOperator
for targetIp = 0.0.0.0; (I have changed it from String as I need to compare it later on to DestinationIP)
2) Multiple markers at this line
- Syntax error on token "p", delete this
token - Packet cannot be resolved to a variable
for line: getLayerHandler().getTransportLayer().receive(Packet p, sourceIP, destinationIP);
The code(modified of Simpleportscanner application) to get the above result is:
public class nnew extends IPApplication
{
public nnew()
{
srcport = 1;
destport = 1024;
targetIp = 0.0.0.0;
originIp = "1.1.1.1";
startTick = 100;
}
public void handleEvent(Event e)
{
getLayerHandler().getTransportLayer().receive(Packet p, sourceIP, destinationIP);
if(destinationIP==targetIp){
return;
}
else{
Random ran = new Random(123L);
byte payload[] = new byte[28];
ran.nextBytes(payload);
getLayerHandler().getTransportLayer().sendUDPPacket(srcport, destport, destinationIP, payload);
}
super.handleEvent(e);
}
public boolean start()
{
//destinationIP = IPFactory.createIPv4Address(targetIp);
TickedEvent e = new TickedEvent(this, startTick);
getLayerHandler().addEvent(e);
return super.start();
}
private int srcport;
private int destport;
//private String targetIp;
private String originIp;
private int startTick;
private IPv4Address destinationIP,targetIp;
private IPv4Address sourceIP;
}
Kindly help! Thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well this are standard Java implementation error and actual the errors messages already point to the solution, e.g.: getLayerHandler().getTransportLayer().receive(Packet p, sourceIP, destinationIP); ==> getLayerHandler().getTransportLayer().receive(p, sourceIP, destinationIP);
Which still would not work since there is no p anywhere in that method.
NeSSi2 already ships with a few example applications, one is a firewall. You could us that implementation as a hint, see de.dailab.nessi.applications.firewall.FirewallApp. This is located in:
I have been trying to develop an application to stop packets from reaching a particular IP address. However I am getting the following 2 errors:
1) Multiple markers at this line
- The left-hand side of an assignment must be a
variable - Syntax error on token ".0", invalid AssignmentOperator
for targetIp = 0.0.0.0; (I have changed it from String as I need to compare it later on to DestinationIP)
2) Multiple markers at this line
- Syntax error on token "p", delete this
token - Packet cannot be resolved to a variable
for line: getLayerHandler().getTransportLayer().receive(Packet p, sourceIP, destinationIP);
The code(modified of Simpleportscanner application) to get the above result is:
public class nnew extends IPApplication
{
}
Kindly help! Thank you!
Well this are standard Java implementation error and actual the errors messages already point to the solution, e.g.: getLayerHandler().getTransportLayer().receive(Packet p, sourceIP, destinationIP); ==> getLayerHandler().getTransportLayer().receive(p, sourceIP, destinationIP);
Which still would not work since there is no p anywhere in that method.
NeSSi2 already ships with a few example applications, one is a firewall. You could us that implementation as a hint, see de.dailab.nessi.applications.firewall.FirewallApp. This is located in:
Hope that helps.