/*---------------------------------------------------------------------------* 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 12372 2010-03-15 02:11:34Z hatamoto_minoru $ *---------------------------------------------------------------------------*/ #ifndef NWCM_H #define NWCM_H #include #include /* 本当のwcmヘッダファイル */ #include #ifdef __cplusplus extern "C" { #endif /*---------------------------------------------------------------------------* * Definitions *---------------------------------------------------------------------------*/ #define NWCM_DEVICE_1 0 /* このドライバで扱えるI/Fは1つだけ */ #define NWCM_VENDOR_NINTENDO 0x0000 #define NWCM_COMMON_CONF_VERSION 0x1100 #define NWCM_INS_CONF_VERSION 0x2100 /** * エラーコード */ #define NWCM_ERROR_BASE 0xffff9000 #define NWCM_ERROR_CODE(code) ((s32)(NWCM_ERROR_BASE|(code))) enum { NWCM_ERR_PARAM = NWCM_ERROR_CODE(1), /* パラメータエラー */ NWCM_ERR_INIT = NWCM_ERROR_CODE(2), /* 初期状態のため実行不可 */ NWCM_ERR_FINISH = NWCM_ERROR_CODE(3), /* 終了状態のため実行不可 */ NWCM_ERR_CONFVER = NWCM_ERROR_CODE(4), /* 設定のバージョンエラー */ NWCM_ERR_STATE = NWCM_ERROR_CODE(5), /* ステートエラー */ NWCM_ERR_EXIST = NWCM_ERROR_CODE(6), /* 既に作成済み */ NWCM_ERR_NOMEM = NWCM_ERROR_CODE(7), /* メモリ不足 */ NWCM_ERR_TIMEOUT = NWCM_ERROR_CODE(8), /* タイムアウト */ NWCM_ERR_NONE = 0 /* 正常終了 */ }; /** * メモリ */ #define NWCM_MEM_BASE 0x00050000 #define NWCM_MEM_NAME(name) ((s32)(NWCM_MEM_BASE|(name))) enum { NWCM_MEM_INSTANCE = NWCM_MEM_NAME(1) }; /** * ステート */ enum { NWCM_STATE_INIT = 0, /* 初期状態 */ NWCM_STATE_WAIT_LINKUP, /* APとのアソシエーション待ち状態 */ NWCM_STATE_ACTIVE, /* 接続完了状態 */ NWCM_STATE_ABORT, /* アソシエーションキャンセル */ NWCM_STATE_MORIBUND /* 切断実行中 */ }; /*---------------------------------------------------------------------------* * Types/Declarations *---------------------------------------------------------------------------*/ #define NWCM_MAC_LEN 6 /** * 無線ドライバが保持するプロトコル情報 */ typedef struct NWCMProtocolList { u16 protocol; /* IP、ARPなど */ NNETInstance *upper_ins; /* 上位インスタンス */ NOSMessageQueueId mq_receive; /* 上記プロトコルを受信したときにパケットを入れるキュー */ } NWCMProtocolList; /** * モジュール全体で使用する設定 */ typedef struct NWCMCommonConfig { u16 vendor; /* NWCM_VENDOR_NINTENDO */ u16 version; /* NWCM_COMMON_CONF_VERSION */ /* パラメータなし */ } NWCMCommonConfig; /** * WEPキー設定構造体 */ /* 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; /** * インスタンス固有設定 */ #define NWCM_BSSID_SIZE WCM_BSSID_SIZE /* BSSIDサイズ */ #define NWCM_ESSID_SIZE WCM_ESSID_SIZE /* ESSIDサイズ */ 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; /** * インスタンス */ #define NWCM_PROTOCOL_NUM 8 /* ARP, RARP, IP, PPPoE Discovery, PPPoE Session */ #define NWCM_UPPER_NUM 2 /* 上位のレイヤ数 */ #define NWCM_MQ_NUM 16 /* 上位へ渡すキューのサイズ */ #define NWCM_MAX_SEND_LEN 1600 typedef struct NWCMMessage { NOSMessageQueue mq; /* 上位用の受信キュー */ NOSMessage mqarray[NWCM_MQ_NUM]; /* 上位用の受信キュー実体 */ } NWCMMessage; typedef struct NWCMInstance { NNETInstance ins; /* 全レイヤ共通に持っているインスタンス情報 */ NWCMInstanceConfig config; /* インスタンス固有設定 */ NWCMProtocolList upper_protocol[NWCM_PROTOCOL_NUM]; /* 上位のプロトコルと送信するメッセージキュー */ s32 upper_protocol_count; NWCMMessage upper_mq[NWCM_UPPER_NUM]; /* 上位用の受信キュー */ s32 upper_ins_count; s32 state; u8 macaddr[NWCM_MAC_LEN]; /* 自MACアドレス */ u8 sendBuf[NWCM_MAX_SEND_LEN]; /* 送信バッファ */ } NWCMInstance; /* WCMのインスタンスからNNETInstanceを取得する */ NN_INLINE NNETInstance *NWCM_GetNNETInstance(NWCMInstance *wcm_ins) { return (NNETInstance *)wcm_ins; } /* NNETInstanceからWCMのインスタンスを取得する */ NN_INLINE NWCMInstance *NWCM_GetNWCMInstance(NNETInstance *ins) { return (NWCMInstance *)ins; } /*---------------------------------------------------------------------------* * Function Prototypes *---------------------------------------------------------------------------*/ /* nwcm_main.c */ extern s32 NWCM_Init(const NNETAllocator *allocator); extern s32 NWCM_Finish(void); extern s32 NWCM_SetCommonConfig(const NWCMCommonConfig *common_conf); extern s32 NWCM_SetInstanceConfig(NWCMInstance *wcm_ins, const NWCMInstanceConfig *ins_conf); extern s32 NWCM_StartupIns(NNETInstance *ins, s32 timeout); extern s32 NWCM_CleanupIns(NNETInstance *ins, s32 timeout); extern s32 NWCM_AbortIns(NNETInstance *ins); extern s32 NWCM_CreateIns(NWCMInstance **wcm_ins, u32 device_id); extern s32 NWCM_DestroyIns(NWCMInstance *wcm_ins); extern s32 NWCM_GetStateIns(NWCMInstance *wcm_ins); extern s32 NWCM_GetUpperAPI(NNETEthernetAPI *wcm_api, NWCMInstance *wcm_ins); extern s32 NWCM_SetUpper(NNETInstance *ins, NNETInstance *upper_ins, u32 *receive_id, u16 entry[]); extern s32 NWCM_ClearUpper(NNETInstance *ins, NNETInstance *upper_ins); extern s32 NWCM_GetMacAddr(NNETInstance *ins, u8 *macaddr); extern s32 NWCM_SetMulticastAddr(NNETInstance *ins, u8 *macaddr); extern s32 NWCM_ClearMulticastAddr(NNETInstance *ins, u8 *macaddr); extern s32 NWCM_Send(NNETInstance *ins, u8 *dstMAC, NOSMessageBuf *mbuf); extern s32 NWCM_Receive(NNETInstance *ins, u32 receive_id, NOSMessageBuf **mbuf); extern 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); #ifdef __cplusplus } #endif /* NWCM_H */ #endif