--- /dev/null
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
+package org.ibex.net;
+
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import org.ibex.util.*;
+
+public class IP {
+
+ /** construct an IP address from four bytes; doesn't throw an exception */
+ public static InetAddress getIP(int a, int b, int c, int d) {
+ try {
+ return InetAddress.getByAddress(new byte[] { (byte)a, (byte)b, (byte)c, (byte)d });
+ } catch (Exception e) {
+ Log.error(IP.class, e);
+ return null;
+ }
+ }
+
+ public static String toString(InetAddress pi) {
+ return
+ (pi.getAddress()[0]&0xff) + "." +
+ (pi.getAddress()[1]&0xff) + "." +
+ (pi.getAddress()[2]&0xff) + "." +
+ (pi.getAddress()[3]&0xff);
+ }
+
+}