1 /*****************************************************************
3 | Neptune - Network :: Xbox Winsock Implementation
5 | (c) 2001-2005 Gilles Boccon-Gibod
6 | Author: Gilles Boccon-Gibod (bok@bok.net)
8 ****************************************************************/
10 /*----------------------------------------------------------------------
12 +---------------------------------------------------------------------*/
16 #include "NptNetwork.h"
17 #include "NptXboxNetwork.h"
19 /*----------------------------------------------------------------------
21 +---------------------------------------------------------------------*/
22 NPT_WinsockSystem::NPT_WinsockSystem() {
23 XNetStartupParams xnsp
;
24 memset(&xnsp
, 0, sizeof(xnsp
));
25 xnsp
.cfgSizeOfStruct
= sizeof(XNetStartupParams
);
26 xnsp
.cfgFlags
= XNET_STARTUP_BYPASS_SECURITY
;
28 // create more memory for networking
29 xnsp
.cfgPrivatePoolSizeInPages
= 64; // == 256kb, default = 12 (48kb)
30 xnsp
.cfgEnetReceiveQueueLength
= 16; // == 32kb, default = 8 (16kb)
31 xnsp
.cfgIpFragMaxSimultaneous
= 16; // default = 4
32 xnsp
.cfgIpFragMaxPacketDiv256
= 32; // == 8kb, default = 8 (2kb)
33 xnsp
.cfgSockMaxSockets
= 64; // default = 64
34 xnsp
.cfgSockDefaultRecvBufsizeInK
= 128; // default = 16
35 xnsp
.cfgSockDefaultSendBufsizeInK
= 128; // default = 16
37 INT err
= XNetStartup(&xnsp
);
39 WORD wVersionRequested
;
41 wVersionRequested
= MAKEWORD(2, 2);
42 WSAStartup( wVersionRequested
, &wsaData
);
44 NPT_WinsockSystem::~NPT_WinsockSystem() {
48 NPT_WinsockSystem
NPT_WinsockSystem::Initializer
;
50 /*----------------------------------------------------------------------
51 | NPT_NetworkInterface::GetNetworkInterfaces
52 +---------------------------------------------------------------------*/
54 NPT_NetworkInterface::GetNetworkInterfaces(NPT_List
<NPT_NetworkInterface
*>& interfaces
)
59 state
= XNetGetTitleXnAddr(&xna
);
61 } while (state
== XNET_GET_XNADDR_PENDING
);
63 if (state
& XNET_GET_XNADDR_STATIC
|| state
& XNET_GET_XNADDR_DHCP
) {
64 NPT_IpAddress
primary_address(ntohl(xna
.ina
.s_addr
));
65 NPT_IpAddress netmask
; /* no support for netmask */
66 NPT_IpAddress
broadcast_address(ntohl(xna
.ina
.s_addr
));
67 NPT_Flags flags
= NPT_NETWORK_INTERFACE_FLAG_BROADCAST
;
70 if (state
& XNET_GET_XNADDR_ETHERNET
) {
71 mac
.SetAddress(NPT_MacAddress::TYPE_ETHERNET
, xna
.abEnet
, 6);
74 // create an interface object
81 NPT_NetworkInterface
* iface
= new NPT_NetworkInterface(iface_name
, mac
, flags
);
83 // set the interface address
84 NPT_NetworkInterfaceAddress
iface_address(
89 iface
->AddAddress(iface_address
);
91 // add the interface to the list
92 interfaces
.Add(iface
);