2 package org.smallfoot.wwn;
4 import gnu.getopt.Getopt;
5 import gnu.getopt.LongOpt;
48 String res = super.toString();
49 if (null == res) res =
"";
51 return res +
"TestDevice";
93 val = val.replaceAll(
":",
"").toLowerCase();
130 else if (val.toLowerCase().equalsIgnoreCase(
"200100110d123400"))
133 else if (provideBase)
147 System.out.println(
"Usage: "+proc+
" -V|--version|-H|--help");
149 System.out.println(
" : "+proc+
" [--briefestimate] [--device[=switch|initiator|target] [--wwn|-w <WWN> [--port|-p <WWN>] [--wwn|-w <WWN> [--wwn|-w <WWN>]]]");
150 System.out.println(
" ie: "+proc+
" -w 2100000b08123450");
151 System.out.println(
" ie: "+proc+
" --wwn 2100000b08123450");
152 System.out.println(
" ie: "+proc+
" --briefestimate -w 2100000b08123450");
153 System.out.println(
" ie: "+proc+
" -w 21:00:00:0b:08:12:34:50");
154 System.out.println(
" ie: "+proc+
" -w 21:00:000b08:123450");
155 System.out.println(
" ie: "+proc+
" -p 21:00:00:0b:08:12:34:50");
156 System.out.println(
" ie: "+proc+
" --device=switch --port 21:00:000b08:123450");
173 public static void main(String args[])
178 java.util.Vector<LongOpt> options =
new java.util.Vector();
191 options.add(
new LongOpt(
"help", LongOpt.NO_ARGUMENT, null,
'H'));
192 options.add(
new LongOpt(
"version", LongOpt.NO_ARGUMENT, null,
'V'));
194 options.add(
new LongOpt(
"device", LongOpt.REQUIRED_ARGUMENT, null,
'd'));
195 options.add(
new LongOpt(
"port", LongOpt.REQUIRED_ARGUMENT, null,
'p'));
196 options.add(
new LongOpt(
"wwn", LongOpt.REQUIRED_ARGUMENT, null,
'w'));
197 options.add(
new LongOpt(
"briefestimate", LongOpt.NO_ARGUMENT, null, 0x1000));
198 options.add(
new LongOpt(
"nobriefestimate", LongOpt.NO_ARGUMENT, null, 0x1001));
203 while ((c = g.getopt()) != -1)
224 if (null == g.getOptarg()) role =
DevRole.TARGETbit;
226 else if (g.getOptarg().toLowerCase().startsWith(
"targ")) role =
DevRole.TARGETbit;
227 else if (g.getOptarg().equalsIgnoreCase(
"storage")) role =
DevRole.TARGETbit;
228 else if (g.getOptarg().equalsIgnoreCase(
"server")) role =
DevRole.INITIATORbit;
229 else if (g.getOptarg().toLowerCase().startsWith(
"init")) role =
DevRole.TARGETbit;
230 else if (g.getOptarg().equalsIgnoreCase(
"switch")) role =
DevRole.SWITCHbit;
240 if ((null == g.getOptarg()) || (16 != g.getOptarg().replaceAll(
":",
"").length()))
241 System.out.println(
"no result: parameter "+g.getOptarg()+
" needs to be a 16-digit hexadecimal");
243 System.out.println(
"no result: WWN "+g.getOptarg()+
" has no descriptor");
244 else System.out.println(wwn.
descPort());
258 if ((null == g.getOptarg()) || (16 != g.getOptarg().replaceAll(
":",
"").length()))
259 System.out.println(
"no result: parameter "+g.getOptarg()+
" needs to be a 16-digit hexadecimal");
261 System.out.println(
"no result: WWN "+g.getOptarg()+
" has no descriptor");
262 else System.out.println(wwn.
toString());
271 System.out.println(g.consistentVersion(
"1.0-76"));
282 m.
usage(g.progname());
292 java.lang.System.exit(0);