public static byte[] inetAddresses2Bytes(InetAddress[] val) {
        if (val == null) {
            return null;
        }
        
        byte[] buf = new byte[val.length * 4];
        for (int i=0; i<val.length; i++) {
            InetAddress addr = val[i];
            if (!(addr instanceof Inet4Address)) {
                throw new IllegalArgumentException("Adress must be of subclass Inet4Address");
            }
            System.arraycopy(addr.getAddress(), 0, buf, i*4, 4);
        }
        return buf;
    }