1 /*---------------------------------------------------------------------------*
2 Project: NET Initialize demo
3 File: config.c
4
5 Copyright 2006 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Log: config.c,v $
14 Revision 1.6 2007/08/01 09:36:29 kitase_hirotake
15 TAB -> SPACE
16
17 Revision 1.5 2007/01/29 07:54:31 terui
18 The implementation of the REXDEMOCreatePeerAddress function was moved to peer.c.
19
20 Revision 1.4 2006/09/25 07:06:13 seiki_masashi
21 Revised so that the network setting from the NAND will be used for configId 0.
22 Revised so that peerName is also acquired from the command line argument.
23
24 Revision 1.3 2006/08/29 07:19:20 adachi_hiroaki
25 Changed prefix. Reorganized others.
26
27 Revision 1.2 2006/08/24 00:43:18 adachi_hiroaki
28 Corrected missing ','
29
30 Revision 1.1 2006/08/24 00:18:57 adachi_hiroaki
31 Added setting code for public release.
32
33
34 $NoKeywords: $
35 *---------------------------------------------------------------------------*/
36
37 #include <revolution/ncd.h>
38 #include <revolution/so.h>
39 #include <string.h> /* For memset() */
40 #include "rexdemo/netconfig.h"
41
42 /*---------------------------------------------------------------------------*/
43
44 BOOL
REXDEMOCreateIfConfig(NCDIfConfig * pIfConfig,u8 configId)45 REXDEMOCreateIfConfig( NCDIfConfig* pIfConfig, u8 configId )
46 {
47 (void)memset( pIfConfig, 0, sizeof( NCDIfConfig ) );
48 switch( configId )
49 {
50 case 0:
51 /* Use the network setting stored in the Wii console NAND flash memory */
52 return FALSE;
53
54 case 1:
55 {
56 pIfConfig->selectedMedia = NCD_IF_SELECT_WIRED;
57 #ifdef NCD_WIRED_LINKTYPE_SUPPORT
58 pIfConfig->netif.wired.linkType = NCD_WIRED_LINKTYPE_AUTO;
59 #endif
60 break;
61 }
62 case 2:
63 {
64 #define SSID1 "TESTSSID"
65 pIfConfig->selectedMedia = NCD_IF_SELECT_WIRELESS;
66 pIfConfig->netif.wireless.rateset = 0; /* Automatic */
67 pIfConfig->netif.wireless.retryLimit = 0; /* Automatic */
68 pIfConfig->netif.wireless.configMethod = NCD_CONFIG_METHOD_MANUAL;
69 {
70 NCDApConfig* pApConfig = &( pIfConfig->netif.wireless.config.manual );
71
72 (void)strcpy( (char*)( pApConfig->ssid ), SSID1 );
73 pApConfig->ssidLength = (u16)strlen( SSID1 );
74 pApConfig->privacy.mode = NCD_PRIVACY_MODE_WEP104;
75 pApConfig->privacy.wep104.keyId = 0;
76 (void)memcpy( pApConfig->privacy.wep104.key[0], "wepkey_WEPKEY", 13 );
77 }
78 }
79 break;
80 default:
81 OSReport("Invalid configuration Id.(%d)", configId);
82 OSHalt("Exiting...");
83 }
84
85 return TRUE;
86 }
87
88 /*---------------------------------------------------------------------------*/
89 BOOL
REXDEMOCreateIpConfig(NCDIpConfig * pIpConfig,u8 configId)90 REXDEMOCreateIpConfig( NCDIpConfig* pIpConfig, u8 configId )
91 {
92 #define MTU 1500
93
94 (void)memset( pIpConfig, 0, sizeof( NCDIpConfig ) );
95 switch( configId )
96 {
97 case 0:
98 /* Use the network setting stored in the Wii console NAND flash memory */
99 return FALSE;
100
101 case 1:
102 {
103 pIpConfig->useDhcp = TRUE;
104 }
105 case 2:
106 {
107 pIpConfig->useDhcp = FALSE;
108 pIpConfig->useProxy = FALSE;
109 REXDEMOSetInAddr( pIpConfig->ip.addr, 192, 168, 0, 101 );
110 REXDEMOSetInAddr( pIpConfig->ip.netmask, 255, 255, 255, 0 );
111 REXDEMOSetInAddr( pIpConfig->ip.gateway, 192, 168, 0, 1 );
112 REXDEMOSetInAddr( pIpConfig->ip.dns1, 192, 168, 0, 1 );
113 REXDEMOSetInAddr( pIpConfig->ip.dns2, 0, 0, 0, 0 );
114 break;
115 }
116 default:
117 OSReport("Invalid configuration Id.(%d)", configId);
118 OSHalt("Exiting...");
119 }
120
121 pIpConfig->adjust.maxTransferUnit = MTU;
122 pIpConfig->adjust.tcpRetransTimeout = 100;
123 pIpConfig->adjust.dhcpRetransCount = 4;
124
125 return TRUE;
126 }
127
128 /*---------------------------------------------------------------------------*
129 End of file
130 *---------------------------------------------------------------------------*/
131