|
@@ -6,11 +6,13 @@ import android.net.wifi.WifiManager;
|
|
|
|
|
|
import org.alfresco.jlan.app.JLANCifsServer;
|
|
|
import org.alfresco.jlan.app.XMLServerConfiguration;
|
|
|
+import org.alfresco.jlan.netbios.NetworkSettings;
|
|
|
import org.alfresco.jlan.server.NetworkServer;
|
|
|
import org.alfresco.jlan.smb.server.CIFSConfigSection;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.net.InetAddress;
|
|
|
+import java.net.UnknownHostException;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.ui.activity.MainActivity;
|
|
|
|
|
@@ -36,6 +38,15 @@ public class CifsServer extends JLANCifsServer {
|
|
|
cifsConfigSection.setHostAnnouncer(true);
|
|
|
cifsConfigSection.setDisableNIOCode(true);
|
|
|
|
|
|
+ WifiManager wifi = (WifiManager) MainActivity.context.getSystemService(Context.WIFI_SERVICE);
|
|
|
+ DhcpInfo dhcp = wifi.getDhcpInfo();
|
|
|
+
|
|
|
+ int ip = dhcp.ipAddress;
|
|
|
+
|
|
|
+ cifsConfigSection.setSMBBindAddress(intToInetAddress(ip));
|
|
|
+ cifsConfigSection.setNetBIOSBindAddress(intToInetAddress(ip));
|
|
|
+ NetworkSettings.setBroadcastMask(getBroadcastAddress());
|
|
|
+
|
|
|
if(cifsConfigSection.hasNetBIOSSMB()){
|
|
|
serverConfiguration.addServer(createNetBIOSServer(serverConfiguration));
|
|
|
}
|
|
@@ -66,4 +77,17 @@ public class CifsServer extends JLANCifsServer {
|
|
|
quads[k] = (byte) (broadcast >> (k * 8));
|
|
|
return InetAddress.getByAddress(quads).toString().substring(1);
|
|
|
}
|
|
|
+
|
|
|
+ public static InetAddress intToInetAddress(int hostAddress) {
|
|
|
+ byte[] addressBytes = { (byte)(0xff & hostAddress),
|
|
|
+ (byte)(0xff & (hostAddress >> 8)),
|
|
|
+ (byte)(0xff & (hostAddress >> 16)),
|
|
|
+ (byte)(0xff & (hostAddress >> 24)) };
|
|
|
+
|
|
|
+ try {
|
|
|
+ return InetAddress.getByAddress(addressBytes);
|
|
|
+ } catch (UnknownHostException e) {
|
|
|
+ throw new AssertionError();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|