Jump to content


Photo

Static Assigned Ip Address


  • Please log in to reply
1 reply to this topic

#1 xirtam

xirtam

    X-S Enthusiast

  • Members
  • 4 posts

Posted 05 May 2003 - 04:00 PM

I am working on a homebrew application and need some assistance with starting up the network. I have the following code which seems to work, but I would like to try something different. I guess this also relates to a few other questions, so I might as well get them off my chest too.

1. XBMP.. that is my dashboard that I am launching this application from... when I launch my app from XBMP does it use the IP address information that I have configured there or does it go out and do a DHCP request from my router? I put the sniffer on the wire but all I see is an arp request from my xbox. Here is the code I am currently using to start up networking:

XNetStartupParams xnsp;
memset(&xnsp, 0, sizeof(xnsp));
xnsp.cfgSizeOfStruct = sizeof(XNetStartupParams);
xnsp.cfgFlags = XNET_STARTUP_BYPASS_SECURITY;
INT err = XNetStartup(&xnsp);


2. How can I configure the xbox with a static IP address (I would like to assign, IP, Subnet mask, default gateway, and nameserver)?

3. Should I be using evo-x, xtoolbox, direct boot from DVD or other dashboard/application to be starting my application or is XBMP fine?

Hope you can help (sample code, advice, random thoughts, etc)
Thanx,
XirtamII (xboxdude@rogers.com)

#2 xirtam

xirtam

    X-S Enthusiast

  • Members
  • 4 posts

Posted 06 May 2003 - 12:53 AM

All right folks.. with some reverse engineering... ok more like some basic understanding of c++ and xbmp source code I was able to figure this one out. Here is an example:

[code=auto:0]
#include <xtl.h>
#include "main.h"
#include "debug.h"
#include <stdio.h>
#include <string.h>

typedef struct
{
DWORD Data_00; // Check Block Start
DWORD Data_04;
DWORD Data_08;
DWORD Data_0c;
DWORD Data_10; // Check Block End

DWORD V1_IP; // 0x14
DWORD V1_Subnetmask; // 0x18
DWORD V1_Defaultgateway; // 0x1c
DWORD V1_DNS1; // 0x20
DWORD V1_DNS2; // 0x24

DWORD Data_28; // Check Block Start
DWORD Data_2c;
DWORD Data_30;
DWORD Data_34;
DWORD Data_38; // Check Block End

DWORD V2_Tag; // V2 Tag "XBV2"

DWORD Flag; // 0x40
DWORD Data_44;

DWORD V2_IP; // 0x48
DWORD V2_Subnetmask; // 0x4c
DWORD V2_Defaultgateway; // 0x50
DWORD V2_DNS1; // 0x54
DWORD V2_DNS2; // 0x58

DWORD Data_xx[0x200-0x5c];

} TXNetConfigParams,*PTXNetConfigParams;

void wait(int waittime)
{
DWORD TIMELIMIT = waittime * 1000;
DWORD dwStart = GetTickCount();
while ((GetTickCount() - dwStart) < TIMELIMIT)
{
// 1 waittime = 1 second!
}
}


void main ()
{
//extern CHAR g_szTitleIP[32];

int localadd;
localadd=1;

// if (!IsEthernetConnected())
// return FALSE;

// if local address is specified
if (localadd == 1)

{
// Thanks and credits to Team Evox for the description of the
// XNetConfigParams structure.

TXNetConfigParams configParams;

debug("Loading network configuration...n");
XNetLoadConfigParams( (LPBYTE) &configParams );
debug("Ready.n");

BOOL bXboxVersion2 = (configParams.V2_Tag == 0x58425632 ); // "XBV2"
BOOL bDirty = FALSE;

debug("User local address: ");
debug("192.168.1.200");
debug("n");

if (bXboxVersion2)
{
if (configParams.V2_IP != inet_addr("192.168.1.200"))
{
configParams.V2_IP = inet_addr("192.168.1.200");
bDirty = TRUE;
}
}
else
{
if (configParams.V1_IP != inet_addr("192.168.1.200"))
{
configParams.V1_IP = inet_addr("192.168.1.200");
bDirty = TRUE;
}
}

debug("User subnet mask: ");
debug("255.255.255.0");
debug("n");

if (bXboxVersion2)
{
if (configParams.V2_Subnetmask != inet_addr("255.255.255.0"))
{
configParams.V2_Subnetmask = inet_addr("255.255.255.0");
bDirty = TRUE;
}
}
else
{
if (configParams.V1_Subnetmask != inet_addr("255.255.255.0"))
{
configParams.V1_Subnetmask = inet_addr("255.255.255.0");
bDirty = TRUE;
}
}

debug("User gateway address: ");
debug("192.168.1.1");
debug("n");

if (bXboxVersion2)
{
if (configParams.V2_Defaultgateway != inet_addr("192.168.1.1"))
{
configParams.V2_Defaultgateway = inet_addr("192.168.1.1");
bDirty = TRUE;
}
}
else
{
if (configParams.V1_Defaultgateway != inet_addr("192.168.1.1"))
{
configParams.V1_Defaultgateway = inet_addr("192.168.1.1");
bDirty = TRUE;
}
}

debug("DNS Settings: ");
debug("142.77.1.1");
debug("n");
if (bXboxVersion2)
{
if (configParams.V2_DNS1 != inet_addr("142.77.1.1"))
{
configParams.V2_DNS1 = inet_addr("142.77.1.1");
bDirty = TRUE;
}
}
else
{
if (configParams.V1_DNS1 != inet_addr("142.77.1.1"))
{
configParams.V1_DNS1 = inet_addr("142.77.1.1");
bDirty = TRUE;
}
}


if (configParams.Flag != (0x04|0x08) )
{
configParams.Flag = 0x04 | 0x08;
bDirty = TRUE;
}

if (bDirty)
{
debug("Updating network configuration...n");
XNetSaveConfigParams( (LPBYTE) &configParams );
debug("Ready.n");
}
}

XNetStartupParams xnsp;
memset(&xnsp, 0, sizeof(xnsp));
xnsp.cfgSizeOfStruct = sizeof(XNetStartupParams);

// Bypass security so that we may connect to 'untrusted' hosts
xnsp.cfgFlags = XNET_STARTUP_BYPASS_SECURITY;
// create more memory for networking
xnsp.cfgPrivatePoolSizeInPages = 64; // == 256kb, default = 12 (48kb)
xnsp.cfgEnetReceiveQueueLength = 16; // == 32kb, default = 8 (16kb)
xnsp.cfgIpFragMaxSimultaneous = 16; // default = 4
xnsp.cfgIpFragMaxPacketDiv256 = 32; // == 8kb, default = 8 (2kb)
xnsp.cfgSockMaxSockets = 64; // default = 64
xnsp.cfgSockDefaultRecvBufsizeInK = 128; // default = 16
xnsp.cfgSockDefaultSendBufsizeInK = 128; // default = 16
INT err = XNetStartup(&xnsp);

XNADDR xna;
DWORD dwState;
do
{
dwState = XNetGetTitleXnAddr(&xna);
Sleep(500);
} while (dwState==XNET_GET_XNADDR_PENDING);

// XNetInAddrToString(xna.ina,g_szTitleIP,32);

WSADATA WsaData;
err = WSAStartup( MAKEWORD(2,2), &WsaData );
// return ( err == NO_ERROR );

char popserver[]= "www.yahoo.com";
char buf[8192];
int results = 0;
WSAEVENT hEvent = WSACreateEvent();
XNDNS* pDns = NULL;
results = XNetDnsLookup(popserver, hEvent, &pDns);
sprintf(buf, "DNS: %drn", results);
debug(buf);



wait(1000);

}




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users