public static Name
fromAddress(byte [] addr) {
	if (addr.length != 4 && addr.length != 16)
		throw new IllegalArgumentException("array must contain " +
						   "4 or 16 elements");
	StringBuffer sb = new StringBuffer();
	if (addr.length == 4) {
		for (int i = addr.length - 1; i >= 0; i--) {
			sb.append(addr[i] & 0xFF);
			if (i > 0)
				sb.append(".");
		}
	} else {
		int [] nibbles = new int[2];
		for (int i = addr.length - 1; i >= 0; i--) {
			nibbles[0] = (addr[i] & 0xFF) >> 4;
			nibbles[1] = (addr[i] & 0xFF) & 0xF;
			for (int j = nibbles.length - 1; j >= 0; j--) {
				sb.append(nibbles[j]);
				if (i > 0 || j > 0)
					sb.append(".");
			}
		}
	}
	try {
		return Name.fromString(sb.toString(), inaddr4);
	}
	catch (TextParseException e) {
		throw new IllegalStateException("name cannot be invalid");
	}
}

public static Name
fromAddress(byte [] addr) {
	if (addr.length != 4 && addr.length != 16)
		throw new IllegalArgumentException("array must contain " +
						   "4 or 16 elements");
	StringBuffer sb = new StringBuffer();
	if (addr.length == 4) {
		for (int i = addr.length - 1; i >= 0; i--) {
			sb.append(addr[i] & 0xFF);
			if (i > 0)
				sb.append(".");
		}
	} else {
		int [] nibbles = new int[2];
		for (int i = addr.length - 1; i >= 0; i--) {
			nibbles[0] = (addr[i] & 0xFF) >> 4;
			nibbles[1] = (addr[i] & 0xFF) & 0xF;
			for (int j = nibbles.length - 1; j >= 0; j--) {
				sb.append(Integer.toHexString(nibbles[j]));
				if (i > 0 || j > 0)
					sb.append(".");
			}
		}
	}
	try {
		if (addr.length == 4)
			return Name.fromString(sb.toString(), inaddr4);
		else
			return Name.fromString(sb.toString(), inaddr6);
	}
	catch (TextParseException e) {
		throw new IllegalStateException("name cannot be invalid");
	}
}
