1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "../gsCommon.h"
#include "../gsPlatformSocket.h"
#include <netex/libnetctl.h>
// ToDo: Move this to PS3 implemenation
HOSTENT * getlocalhost(void)
{ // Global storage
#define MAX_IPS 10
static HOSTENT localhost;
static char * aliases = NULL;
static char * ipPtrs[MAX_IPS + 1];
static unsigned int ips [MAX_IPS];
int r;
union CellNetCtlInfo gCellNetInfo;
// Todo: support mutliple ip's.
// initialize the host
localhost.h_name = "localhost";
localhost.h_aliases = &aliases;
localhost.h_addrtype = AF_INET;
localhost.h_length = sizeof(unsigned int);
localhost.h_addr_list = ipPtrs;
ipPtrs[0] = (char *)&ips[0];
ipPtrs[1] = NULL;
// to do, cache this, and do this once at init.
r = cellNetCtlGetInfo( CELL_NET_CTL_INFO_IP_ADDRESS,&gCellNetInfo );
if (r == CELL_OK)
{
ips[0] = inet_addr(gCellNetInfo.ip_address);
return &localhost;
}
else
return NULL;
}
|