From 4291d52164a2838c46d0806eedad266fdb9112b6 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 16 Mar 2005 03:24:04 +0000 Subject: [PATCH] convert String protocol to int --- .../java/src/net/hyperic/sigar/NetFlags.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bindings/java/src/net/hyperic/sigar/NetFlags.java b/bindings/java/src/net/hyperic/sigar/NetFlags.java index 87429dab..8ffe76be 100644 --- a/bindings/java/src/net/hyperic/sigar/NetFlags.java +++ b/bindings/java/src/net/hyperic/sigar/NetFlags.java @@ -92,6 +92,26 @@ public class NetFlags { public static final int TCP_CLOSING = 11; public static final int TCP_UNKNOWN = 12; + public static int getConnectionProtocol(String protocol) + throws SigarException { + + if (protocol.equals("tcp")) { + return NetFlags.CONN_TCP; + } + else if (protocol.equals("udp")) { + return NetFlags.CONN_UDP; + } + else if (protocol.equals("raw")) { + return NetFlags.CONN_RAW; + } + else if (protocol.equals("unix")) { + return NetFlags.CONN_UNIX; + } + + String msg = "Protocol '" + protocol + "' not supported"; + throw new SigarException(msg); + } + /** * @param flags network interface flags. * @return String representation of network interface flags.