/*---------------------------------------------------------------------------* Project: NWCM Library File: nwcm.h Copyright (C) 2008 Nintendo All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. @version $Id: nwcm.h 16441 2010-05-20 00:57:11Z takiguchi_shinichi $ *---------------------------------------------------------------------------*/ #ifndef NWCM_H #define NWCM_H #include #ifdef __cplusplus extern "C" { #endif /*---------------------------------------------------------------------------* * WCM Temporary Definitions *---------------------------------------------------------------------------*/ // 各種制御用定数 // 各種データサイズ(サイズの単位はバイト) #define WM_SIZE_BSSID 6 #define WM_SIZE_SSID 32 #define WCM_CAM_LIFETIME 80 // CAM ライフタイム( 8 秒 ) #define WCM_BSSID_SIZE WM_SIZE_BSSID // BSS-ID のサイズ ( 6 バイト ) #define WCM_ESSID_SIZE WM_SIZE_SSID // ESS-ID の最大サイズ ( 32 バイト ) #define WCM_OPTION_TEST_AUTH 0x00080000 #define WCM_OPTION_FILTER_AUTH 0x00040000 // WEP 暗号化モード種別 #define WCM_WEPMODE_NONE 0 // 暗号化なし #define WCM_WEPMODE_40 1 // RC4 ( 40 ビット ) 暗号化モード #define WCM_WEPMODE_104 2 // RC4 ( 104 ビット ) 暗号化モード #define WCM_WEPMODE_128 3 // RC4 ( 128 ビット ) 暗号化モード // AP との認証モード #define WCM_OPTION_TEST_AUTH 0x00080000 #define WCM_OPTION_FILTER_AUTH 0x00040000 #define WCM_OPTION_MASK_AUTH (WCM_OPTION_TEST_AUTH | WCM_OPTION_FILTER_AUTH) #define WCM_OPTION_AUTH_OPENSYSTEM (WCM_OPTION_TEST_AUTH | 0x00000000) #define WCM_OPTION_AUTH_SHAREDKEY (WCM_OPTION_TEST_AUTH | 0x00040000) #define WM_SIZE_WEPKEY 80 #define WCM_WEP_SIZE WM_SIZE_WEPKEY // 80 バイト /*---------------------------------------------------------------------------* * Definitions *---------------------------------------------------------------------------*/ #define NWCM_DEVICE_1 0 /* ���̃h���C�o�ň�����I/F��1���� */ #define NWCM_VENDOR_NINTENDO 0x0000 #define NWCM_COMMON_CONF_VERSION 0x1100 #define NWCM_INS_CONF_VERSION 0x2100 #define NWCM_MEM_BASE 0x00050000 #define NWCM_MEM_NAME(name) ((s32)(NWCM_MEM_BASE|(name))) enum { NWCM_MEM_INSTANCE = NWCM_MEM_NAME(1) }; #define WM_SIZE_USER_GAMEINFO 112 // GameInfoのユーザー領域の最大サイズ #define WM_SIZE_USERNAME 8 #define WM_SIZE_GAMENAME 16 typedef struct WMGameInfo { u16 magicNumber; // == 0x0001 u8 ver; // GameInfo Version 1 u8 platform; // DS: 0, Wii: 8 u32 ggid; u16 tgid; u8 userGameInfoLength; // ユーザー領域の長さ union { // (CS_Flag):1, (KS_Flag):1, multibootFlag:1, entryFlag:1 u8 gameNameCount_attribute; // 互換のための旧名 u8 attribute; }; u16 parentMaxSize; //親機最大送信サイズ u16 childMaxSize; //子機最大送信サイズ union { u16 userGameInfo[WM_SIZE_USER_GAMEINFO / sizeof(u16)]; // ユーザー領域(最大112バイト (暫定)) struct { u16 userName[WM_SIZE_USERNAME / sizeof(u16)]; // WM_SIZE_USERNAME -> 8 u16 gameName[WM_SIZE_GAMENAME / sizeof(u16)]; // WM_SIZE_GAMENAME -> 16 u16 padd1[44]; // pad -> 88 } old_type; // 計 112バイト }; } WMGameInfo, WMgameInfo; typedef struct WCMBssDesc { u16 length; // 2 u16 rssi; // 4 u8 bssid[WM_SIZE_BSSID]; // 10 u16 ssidLength; // 12 u8 ssid[WM_SIZE_SSID]; // 44 u16 capaInfo; // 46 struct { u16 basic; // 48 u16 support; // 50 } rateSet; u16 beaconPeriod; // 52 u16 dtimPeriod; // 54 u16 channel; // 56 u16 cfpPeriod; // 58 u16 cfpMaxDuration; // 60 u16 gameInfoLength; // 62 union { u16 otherElementCount; u16 elementCount; }; // 64 union { WMGameInfo gameInfo; u16 elements[1]; }; } WCMBssDesc; /** * �X�e�[�g */ enum { NWCM_STATE_INIT = 0, /* ������ */ NWCM_STATE_WAIT_LINKUP, /* AP�Ƃ̃A�\�V�G�[�V�����҂���� */ NWCM_STATE_ACTIVE, /* �ڑ�������� */ NWCM_STATE_ABORT, /* �A�\�V�G�[�V�����L�����Z�� */ NWCM_STATE_MORIBUND /* �ؒf���s�� */ }; /*---------------------------------------------------------------------------* * Types/Declarations *---------------------------------------------------------------------------*/ #define NWCM_MAC_LEN 6 /** * ����h���C�o���ێ�����v���g�R����� */ typedef struct NWCMProtocolList { u16 protocol; /* IP�AARP�Ȃ� */ NNETInstance *upper_ins; /* ��ʃC���X�^���X */ NOSMessageQueueId mq_receive; /* ��L�v���g�R������M�����Ƃ��Ƀp�P�b�g�����L���[ */ } NWCMProtocolList; /** * ���W���[���S�̂Ŏg�p����ݒ� */ typedef struct NWCMCommonConfig { u16 vendor; /* NWCM_VENDOR_NINTENDO */ u16 version; /* NWCM_COMMON_CONF_VERSION */ /* �p�����[�^�Ȃ� */ } NWCMCommonConfig; /** * �C���X�^���X */ #define NWCM_PROTOCOL_NUM 8 /* ARP, RARP, IP, PPPoE Discovery, PPPoE Session */ #define NWCM_UPPER_NUM 2 /* ��ʂ̃��C���� */ #define NWCM_MQ_NUM 16 /* ��ʂ֓n���L���[�̃T�C�Y */ #define NWCM_MAX_SEND_LEN 1600 typedef struct NWCMMessage { NOSMessageQueue mq; /* ��ʗp�̎�M�L���[ */ NOSMessage mqarray[NWCM_MQ_NUM]; /* ��ʗp�̎�M�L���[���� */ } NWCMMessage; #define NWCM_VENDOR_NINTENDO 0x0000 #define NWCM_COMMON_CONF_VERSION 0x1100 #define NWCM_INS_CONF_VERSION 0x2100 /** * インスタンス固有設定 */ #define NWCM_BSSID_SIZE WCM_BSSID_SIZE /* BSSIDサイズ */ #define NWCM_ESSID_SIZE WCM_ESSID_SIZE /* ESSIDサイズ */ /* APとの認証モード */ #define NWCM_OPTION_TEST_AUTH WCM_OPTION_TEST_AUTH #define NWCM_OPTION_FILTER_AUTH WCM_OPTION_FILTER_AUTH #define NWCM_OPTION_MASK_AUTH WCM_OPTION_MASK_AUTH #define NWCM_OPTION_AUTH_OPENSYSTEM WCM_OPTION_AUTH_OPENSYSTEM /* WEP 暗号化モード種別 */ #define NWCM_WEPMODE_NONE WCM_WEPMODE_NONE /* 暗号化なし */ #define NWCM_WEPMODE_40 WCM_WEPMODE_40 /* RC4 ( 40 ビット ) 暗号化モード */ #define NWCM_WEPMODE_104 WCM_WEPMODE_104 /* RC4 ( 104 ビット ) 暗号化モード */ #define NWCM_WEPMODE_128 WCM_WEPMODE_128 /* RC4 ( 128 ビット ) 暗号化モード */ #define NWCM_SIZE_WEPKEY WCM_WEP_SIZE /* WEPキー長 */ typedef struct NWCMWepDesc { u8 mode; /* WEP 暗号化モード ( WCM_WEPMODE_* ) */ u8 keyId; /*/ WEP キー ID ( 0 ~ 3 ) */ u8 key[NWCM_SIZE_WEPKEY]; /* WEP キーデータ列[ 20 * 4 バイト ] */ } NWCMWepDesc; typedef NWCMWepDesc WCMWepDesc; typedef struct NWCMInstanceConfig { u16 vendor; /* NWCM_VENDOR_NINTENDO */ u16 version; /* NWCM_INS_CONF_VERSION */ u8 bssId[NWCM_BSSID_SIZE]; NWCMWepDesc wepDesc; u8 essId[NWCM_ESSID_SIZE]; u32 auth_option; } NWCMInstanceConfig; typedef struct NWCMInstance { NNETInstance ins; /* �S���C�����ʂɎ����Ă���C���X�^���X��� */ NWCMInstanceConfig config; /* �C���X�^���X�ŗL�ݒ� */ NWCMProtocolList upper_protocol[NWCM_PROTOCOL_NUM]; /* ��ʂ̃v���g�R���Ƒ��M���郁�b�Z�[�W�L���[ */ s32 upper_protocol_count; NWCMMessage upper_mq[NWCM_UPPER_NUM]; /* ��ʗp�̎�M�L���[ */ s32 upper_ins_count; s32 state; u8 macaddr[NWCM_MAC_LEN]; /* ��MAC�A�h���X */ u8 sendBuf[NWCM_MAX_SEND_LEN]; /* ���M�o�b�t�@ */ } NWCMInstance; /* WCM�̃C���X�^���X����NNETInstance���擾���� */ NN_INLINE NNETInstance *NWCM_GetNNETInstance(NWCMInstance *wcm_ins) { return (NNETInstance *)wcm_ins; } /* NNETInstance����WCM�̃C���X�^���X���擾���� */ NN_INLINE NWCMInstance *NWCM_GetNWCMInstance(NNETInstance *ins) { return (NWCMInstance *)ins; } /*---------------------------------------------------------------------------* * Function Prototypes *---------------------------------------------------------------------------*/ /* nwcm_main.c */ s32 NWCM_Init(const NNETAllocator *allocator); s32 NWCM_Finish(void); s32 NWCM_SetCommonConfig(const NWCMCommonConfig *common_conf); s32 NWCM_SetInstanceConfig(NWCMInstance *wcm_ins, const NWCMInstanceConfig *ins_conf); s32 NWCM_StartupIns(NNETInstance *ins, s32 timeout); s32 NWCM_CleanupIns(NNETInstance *ins, s32 timeout); s32 NWCM_AbortIns(NNETInstance *ins); s32 NWCM_CreateIns(NWCMInstance **wcm_ins, u32 device_id); s32 NWCM_DestroyIns(NWCMInstance *wcm_ins); s32 NWCM_GetStateIns(NWCMInstance *wcm_ins); s32 NWCM_GetUpperAPI(NNETEthernetAPI *wcm_api, NWCMInstance *wcm_ins); s32 NWCM_SetUpper(NNETInstance *ins, NNETInstance *upper_ins, u32 *receive_id, u16 entry[]); s32 NWCM_ClearUpper(NNETInstance *ins, NNETInstance *upper_ins); s32 NWCM_GetMacAddr(NNETInstance *ins, u8 *macaddr); s32 NWCM_SetMulticastAddr(NNETInstance *ins, u8 *macaddr); s32 NWCM_ClearMulticastAddr(NNETInstance *ins, u8 *macaddr); s32 NWCM_Send(NNETInstance *ins, u8 *dstMAC, NOSMessageBuf *mbuf); s32 NWCM_Receive(NNETInstance *ins, u32 receive_id, NOSMessageBuf **mbuf); s32 NWCM_CancelReceive(NNETInstance *ins, u32 receive_id); #ifdef NDEBUG_ENABLE extern void NWCM_Dummy_Recv(const u8 *srcAddr, const u8 *dstAddr, const u8 *buf, s32 len); #endif /* nwcm_state.c */ extern void NWCM_ChangeStateIns(NWCMInstance *ins, s32 state); extern NWCMCommonConfig nwcmCommonConfig; extern NWCMInstance *wcmIns; extern NWCMInstanceConfig CU_nwcmInsConfig; #ifdef __cplusplus } #endif /* NWCM_H */ #endif