package net.hyperic.sigar;

public class RPC {

    public static final int UDP = NetFlags.CONN_UDP;
    public static final int TCP = NetFlags.CONN_TCP;

    public static final long NFS = 100003;

    public static native boolean ping(String hostname,
                                      int protocol,
                                      long program,
                                      long version);

    public static boolean ping(String hostname, long program) {
        return ping(hostname, UDP, program, 2);
    }
}

@@ -25,26 +25,139 @@
 r;%0A%0A
-public class RPC %7B
+import java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Apublic class RPC %7B%0A%0A    private static Map programs = null;
 %0A%0A  
@@ -265,52 +265,8 @@
 P;%0A%0A
-    public static final long NFS = 100003;%0A%0A
     
@@ -525,70 +525,1367 @@
 ame,
- long program) %7B%0A        return ping(hostname, UDP, program, 2
+%0A                               int protocol,%0A                               String program,%0A                               long version) %7B%0A        return ping(hostname,%0A                    protocol,%0A                    getProgram(program),%0A                    version);%0A    %7D%0A%0A    public static boolean ping(String hostname, long program) %7B%0A        return ping(hostname, UDP, program, 2);%0A    %7D%0A%0A    public static boolean ping(String hostname, String program) %7B%0A        return ping(hostname, UDP, program, 2);%0A    %7D%0A%0A    private static void parse(String fileName) %7B%0A        programs = new HashMap();%0A        NetServices.parse(%22/etc/rpc%22, new NetServices.EntryReader() %7B%0A            public void process(String program, String num, List aliases) %7B%0A                programs.put(program, num);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    /**%0A     * @return RPC program number as defined in /etc/rpc%0A     */%0A    public static long getProgram(String program) %7B%0A        if (programs == null) %7B%0A            parse(%22/etc/rpc%22);%0A        %7D%0A%0A        Long num;%0A        Object obj = programs.get(program);%0A        if (obj == null) %7B%0A            return -1;%0A        %7D%0A        if (obj instanceof Long) %7B%0A            num = (Long)obj;%0A        %7D%0A        else %7B%0A            num = Long.valueOf((String)obj);%0A            programs.put(program, num);%0A        %7D%0A%0A        return num.longValue(
 );%0A 

add mapping from /etc/rpc