|
From: <cr...@us...> - 2008-05-09 13:14:37
|
Revision: 4074
http://jnode.svn.sourceforge.net/jnode/?rev=4074&view=rev
Author: crawley
Date: 2008-05-09 06:14:24 -0700 (Fri, 09 May 2008)
Log Message:
-----------
Converted ArpCommand
Modified Paths:
--------------
trunk/net/descriptors/org.jnode.net.command.xml
trunk/net/src/net/org/jnode/net/command/ArpCommand.java
Modified: trunk/net/descriptors/org.jnode.net.command.xml
===================================================================
--- trunk/net/descriptors/org.jnode.net.command.xml 2008-05-09 12:42:23 UTC (rev 4073)
+++ trunk/net/descriptors/org.jnode.net.command.xml 2008-05-09 13:14:24 UTC (rev 4074)
@@ -38,7 +38,14 @@
<alias name="net" class="org.jnode.net.command.NetCommand"/>
<alias name="rpcinfo" class="org.jnode.net.command.RpcInfoCommand"/>
</extension>
-
+
+ <extension point="org.jnode.shell.syntaxes">
+ <syntax alias="arp">
+ <empty description="List the ARP cache"/>
+ <option argLabel="clear" shortName="c" longName="clear" description="Clear the ARP cache"/>
+ </syntax>
+ </extension>
+
<extension point="org.jnode.security.permissions">
<permission class="java.net.SocketPermission" name="*" actions="connect,resolve"/>
<permission class="java.net.SocketPermission" name="*:1024-" actions="listen,accept"/>
Modified: trunk/net/src/net/org/jnode/net/command/ArpCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/ArpCommand.java 2008-05-09 12:42:23 UTC (rev 4073)
+++ trunk/net/src/net/org/jnode/net/command/ArpCommand.java 2008-05-09 13:14:24 UTC (rev 4074)
@@ -24,29 +24,29 @@
import java.io.InputStream;
import java.io.PrintStream;
+import org.jnode.driver.net.NetworkException;
+import org.jnode.net.NoSuchProtocolException;
import org.jnode.net.arp.ARPCacheEntry;
import org.jnode.net.arp.ARPNetworkLayer;
import org.jnode.net.ethernet.EthernetConstants;
import org.jnode.net.util.NetUtils;
-import org.jnode.shell.AbstractCommand;
+import org.jnode.shell.AbstractCommand;
import org.jnode.shell.CommandLine;
-import org.jnode.shell.help.Help;
-import org.jnode.shell.help.Parameter;
-import org.jnode.shell.help.ParsedArguments;
-import org.jnode.shell.help.Syntax;
+import org.jnode.shell.syntax.Argument;
+import org.jnode.shell.syntax.FlagArgument;
/**
* @author epr
*/
public class ArpCommand extends AbstractCommand {
- static final Parameter PARAM_DELETE = new Parameter("d", "delete the ARP cache", Parameter.MANDATORY);
+ private final FlagArgument FLAG_CLEAR =
+ new FlagArgument("clear", Argument.OPTIONAL, "if set, clear the ARP cache");
- public static Help.Info HELP_INFO = new Help.Info("arp",
- new Syntax[] {
- new Syntax("Print ARP cache"),
- new Syntax("Clear ARP cache", new Parameter[] { PARAM_DELETE })
- });
+ public ArpCommand() {
+ super("print or clear the ARP cache");
+ registerArguments(FLAG_CLEAR);
+ }
/**
* Execute this command
@@ -55,16 +55,17 @@
new ArpCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception {
- ParsedArguments cmdLine = HELP_INFO.parse(commandLine);
-
+ public void execute(CommandLine commandLine, InputStream in,
+ PrintStream out, PrintStream err) throws NoSuchProtocolException, NetworkException {
+
ARPNetworkLayer arp = (ARPNetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP);
- if (PARAM_DELETE.isSet(cmdLine)) {
+ if (FLAG_CLEAR.isSet()) {
arp.getCache().clear();
- System.out.println("Cleared the ARP cache");
- } else {
+ out.println("Cleared the ARP cache");
+ }
+ else {
for (ARPCacheEntry entry : arp.getCache().entries()) {
- System.out.println(entry);
+ out.println(entry);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|