import java.util.*; import java.util.zip.*; import java.util.List; import java.util.regex.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; import javax.swing.table.*; import java.io.*; import java.net.*; import java.lang.reflect.*; import java.lang.ref.*; import java.lang.management.*; import java.security.*; import java.security.spec.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.imageio.*; import java.math.*; import android.net.*; import android.net.wifi.WifiManager; import android.content.Context; public class main { public static void main(String[] args) throws Exception { String s_dns1 ; String s_dns2; String s_gateway; String s_ipAddress; String s_leaseDuration; String s_netmask; String s_serverAddress; DhcpInfo d; WifiManager wifii; wifii = (WifiManager) androidContext().getSystemService(Context.WIFI_SERVICE); d=wifii.getDhcpInfo(); s_dns1="DNS 1: "+intToIp(d.dns1); s_dns2="DNS 2: "+intToIp(d.dns2); s_gateway="Default Gateway: "+intToIp(d.gateway); s_ipAddress="IP Address: "+intToIp(d.ipAddress); s_leaseDuration="Lease Time: "+intToIp(d.leaseDuration); s_netmask="Subnet Mask: "+intToIp(d.netmask); s_serverAddress="Server IP: "+intToIp(d.serverAddress); String text = "Network Info\n"+s_dns1+"\n"+s_dns2+"\n"+s_gateway+"\n"+s_ipAddress+"\n"+s_leaseDuration+"\n"+s_netmask+"\n"+s_serverAddress; print(text); } static String intToIp(int addr) { return ((addr & 0xFF) + "." + ((addr >>>= 8) & 0xFF) + "." + ((addr >>>= 8) & 0xFF) + "." + ((addr >>>= 8) & 0xFF)); } static Context androidContext() { return getAndroidContext(); } static volatile StringBuffer local_log = new StringBuffer(); // not redirected static volatile StringBuffer print_log = local_log; // might be redirected, e.g. to main bot // in bytes - will cut to half that static volatile int print_log_max = 1024*1024; static volatile int local_log_max = 100*1024; static boolean print_silent; // total mute if set static void print() { print(""); } // slightly overblown signature to return original object... static A print(A o) { if (print_silent) return o; String s = String.valueOf(o) + "\n"; StringBuffer loc = local_log; StringBuffer buf = print_log; int loc_max = print_log_max; if (buf != loc && buf != null) { print_append(buf, s, print_log_max); loc_max = local_log_max; } if (loc != null) print_append(loc, s, loc_max); System.out.print(s); return o; } static void print(long l) { print(String.valueOf(l)); } static void print(char c) { print(String.valueOf(c)); } static void print_append(StringBuffer buf, String s, int max) { synchronized(buf) { buf.append(s); max /= 2; if (buf.length() > max) try { int newLength = max/2; int ofs = buf.length()-newLength; String newString = buf.substring(ofs); buf.setLength(0); buf.append("[...] ").append(newString); } catch (Exception e) { buf.setLength(0); } } } static Object androidContext; static Context getAndroidContext() { return (Context) androidContext; } }