Index: Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp
===================================================================
--- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp	(Revision 5216)
+++ Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp	(Arbeitskopie)
@@ -46,12 +46,13 @@
 #endif
 
 #include "WII_IPC_HLE_Device_net.h"
+#include "FileUtil.h"
 #include <stdio.h>
+#include <string>
 #ifdef _WIN32
 #include <ws2tcpip.h>
 #else
 #include <sys/types.h>
-#include <sys/socket.h> 
 #include <sys/socket.h>
 #include <netinet/in.h>
 #endif
@@ -184,30 +185,89 @@
 	return true;
 }
 
-bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress) 
-{ 
+bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
+{
 	u32 ReturnValue = 0;
 
 	SIOCtlVBuffer CommandBuffer(_CommandAddress);
 
 	switch (CommandBuffer.Parameter)
 	{
-      // WiiMenu
-	case IOCTL_NCD_GETLINKSTATUS: // 32 Out. 5th
-    case IOCTL_NCD_SETIFCONFIG3: // ??? It seems that is related to Write and Read information
-    case IOCTL_NCD_SETIFCONFIG4: // 7004 In, 32 Out. 4th
-    case 0x05: // 7004 Out, 32 Out. 2nd, 3rd
-    case 0x06:
-    case 0x08: // 32 Out, 6 Out. 1st
-        //break;
+	case IOCTLV_NCD_GETIFCONFIG: // 7004 out, 32 out, name guessed by function
+	// first out buffer gets filled with contents of /shared2/sys/net/02/config.dat
+	// TODO: What's the second output buffer for?
+	{
+		INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETIFCONFIG");
 
-	default:		
-		INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter);
+		// read network configuration file
+		std::string filename(File::GetUserPath(D_WIIUSER_IDX));
+		filename.append("shared2/sys/net/02/config.dat");
+		FILE *file = fopen(filename.c_str(), "rb");
+		if (file == NULL)
+		{
+			// TODO: What does a real Wii do in this case?
+			INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETIFCONFIG failed to open %s", filename.c_str());
+			break;
+		}
+		network_config_t cfg;
+		if (fread(&cfg, sizeof(network_config_t), 1, file) != 1)
+		{
+			// TODO: What does a real Wii do in this case?
+			INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETIFCONFIG failed to read %d bytes from %s", sizeof(network_config_t), filename.c_str());
+			break;
+		}
+		fclose(file);
+
+		// fill output buffer, taking care of endianness
+		u32 addr = CommandBuffer.PayloadBuffer.at(0).m_Address;
+		Memory::WriteBigEData((const u8*)&cfg, addr, 8);
+		addr += 8;
+		for (unsigned int i = 0;i < 3; i++)
+		{
+			netcfg_connection_t *conn = &cfg.connection[i];
+
+			Memory::WriteBigEData((const u8*)conn, addr, 26);
+			Memory::Write_U16(Common::swap16(cfg.connection[i].mtu), addr+26);
+			Memory::WriteBigEData((const u8*)conn->padding_3, addr+28, 8);
+
+			Memory::WriteBigEData((const u8*)&conn->proxy_settings, addr+36, 260);
+			Memory::Write_U16(Common::swap16(conn->proxy_settings.proxy_port), addr+296);
+			Memory::WriteBigEData((const u8*)&conn->proxy_settings.proxy_username, addr+298, 65);
+			Memory::Write_U8(conn->padding_4, addr+363);
+
+			Memory::WriteBigEData((const u8*)&conn->proxy_settings_copy, addr+364, 260);
+			Memory::Write_U16(Common::swap16(conn->proxy_settings_copy.proxy_port), addr+624);
+			Memory::WriteBigEData((const u8*)&conn->proxy_settings_copy.proxy_username, addr+626, 65);
+			Memory::WriteBigEData((const u8*)conn->padding_5, addr+691, 1641);
+			addr += sizeof(netcfg_connection_t);
+		}
+		ReturnValue = 0;
 		break;
 	}
+
+	case IOCTLV_NCD_SETIFCONFIG4: // 7004 In, 32 Out. 4th
+		INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_SETIFCONFIG4");
+		break;
+
+	case 0x05: // 7004 Out, 32 Out. 2nd, 3rd
+		INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCtlV 0x5");
+		break;
+
+	case IOCTLV_NCD_GETLINKSTATUS: // 32 Out. 5th
+		INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS");
+		break;
+
+	case 0x08: // 32 Out, 6 Out. 1st
+		INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCtlV 0x8");
+		break;
+
+	default:
+		INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE IOCtlV: %#x", CommandBuffer.Parameter);
+		break;
+	}
+
 	Memory::Write_U32(ReturnValue, _CommandAddress+4);
-
-	return true; 
+	return true;
 }
 
 // **********************************************************************************
Index: Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h
===================================================================
--- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h	(Revision 5216)
+++ Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h	(Arbeitskopie)
@@ -20,6 +20,91 @@
 
 #include "WII_IPC_HLE_Device.h"
 
+// data layout of the network configuration file (/shared2/sys/net/02/config.dat)
+// needed for /dev/net/ncd/manage
+#pragma pack(1)
+typedef struct
+{
+	u8 use_proxy;             // 0x00 -> no proxy;  0x01 -> proxy
+	u8 use_proxy_userandpass; // 0x00 -> don't use username and password;  0x01 -> use username and password
+	u8 padding_1[2];
+	u8 proxy_name[255];
+	u8 padding_2;
+	u16 proxy_port;           // 0-34463
+	u8 proxy_username[32];
+	u8 padding_3;
+	u8 proxy_password[32];
+} netcfg_proxy_t;
+
+typedef struct
+{
+	// settings common to both wired and wireless connections
+	u8 flags; //  Connection selected
+	          //  | ?
+	          //  | | Internet test passed
+	          //  | | | Use Proxy (1 -> on; 0 -> off)
+	          //  | | | |
+	          //  1 0 1 0  0 1 1 0
+	          //           | | | |
+	          //           | | | Interface (0 -> Internal wireless; 1 -> Wired LAN adapter)
+	          //           | | DNS source (0 -> Manual; 1 -> DHCP)
+	          //           | IP source (0 -> Manual; 1 -> DHCP)
+	          //           ?
+
+	u8 padding_1[3];
+
+	u8 ip[4];
+	u8 netmask[4];
+	u8 gateway[4];
+	u8 dns1[4];
+	u8 dns2[4];
+	u8 padding_2[2];
+
+	u16 mtu;         // 0 or 576-1500
+	u8 padding_3[8];
+
+	netcfg_proxy_t proxy_settings;
+	u8 padding_4;
+
+	netcfg_proxy_t proxy_settings_copy; // seems to be a duplicate of proxy_settings
+	u8 padding_5[1297];
+
+	// wireless specific settings
+	u8 ssid[32];        // access Point name.
+
+	u8 padding_6;
+	u8 ssid_length;     // length of ssid in bytes.
+	u8 padding_7[2];
+
+	u8 padding_8;
+	u8 encryption;      // (probably) encryption.  OPN: 0x00, WEP64: 0x01, WEP128: 0x02 WPA-PSK (TKIP): 0x04, WPA2-PSK (AES): 0x05, WPA-PSK (AES): 0x06
+	u8 padding_9[2];
+
+	u8 padding_10;
+	u8 key_length;      // length of key in bytes.  0x00 for WEP64 and WEP128.
+	u8 unknown;         // 0x00 or 0x01 toogled with a WPA-PSK (TKIP) and with a WEP entered with hex instead of ascii.
+	u8 padding_11;
+
+	u8 key[64];         // encryption key; for WEP, key is stored 4 times (20 bytes for WEP64 and 52 bytes for WEP128) then padded with 0x00
+	u8 padding_12[236];
+} netcfg_connection_t;
+
+typedef struct
+{
+	u8 header0;    // 0x00
+	u8 header1;    // 0x00
+	u8 header2;    // 0x00
+	u8 header3;    // 0x00
+	u8 header4;    // 0x01 if there's at least one valid connection to the Internet.
+	u8 header5;    // 0x00
+	u8 header6;    // always 0x07?
+	u8 header7;    // 0x00
+
+	netcfg_connection_t connection[3];
+} network_config_t;
+#pragma pack()
+
+
 // **********************************************************************************
 // KD is the IOS module responsible for implementing WiiConnect24 functionality. It
 // can perform HTTPS downloads, send and receive mail via SMTP, and execute a
@@ -205,7 +290,7 @@
 };
 
 // **********************************************************************************
-// Seems like just wireless stuff?
+// Interface for reading and changing network configuration (probably some other stuff as well)
 class CWII_IPC_HLE_Device_net_ncd_manage : public IWII_IPC_HLE_Device
 {
 public:
@@ -219,11 +304,11 @@
 
 private:
 	enum {
-		IOCTL_NCD_UNK1				= 1, // NCDLockWirelessDriver
-		IOCTL_NCD_UNK2				= 2, // NCDUnlockWirelessDriver
-		IOCTL_NCD_SETIFCONFIG3		= 3,
-		IOCTL_NCD_SETIFCONFIG4		= 4, // NCDGetWirelessMacAddress
-		IOCTL_NCD_GETLINKSTATUS		= 7 // NCDGetLinkStatus
+		IOCTLV_NCD_UNK1				= 1, // NCDLockWirelessDriver
+		IOCTLV_NCD_UNK2				= 2, // NCDUnlockWirelessDriver
+		IOCTLV_NCD_GETIFCONFIG		= 3,
+		IOCTLV_NCD_SETIFCONFIG4		= 4, // NCDGetWirelessMacAddress
+		IOCTLV_NCD_GETLINKSTATUS		= 7 // NCDGetLinkStatus
 	};
 };
 
