/*---------------------------------------------------------------------------* 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 /* The real wcm header file */ #include #ifdef __cplusplus extern "C" { #endif /*---------------------------------------------------------------------------* * Definitions *---------------------------------------------------------------------------*/ #define NWCM_DEVICE_1 0 /* Only 1 interface can be used with this driver */ #define NWCM_VENDOR_NINTENDO 0x0000 #define NWCM_COMMON_CONF_VERSION 0x1100 #define NWCM_INS_CONF_VERSION 0x2100 /* Please see man pages for details */ #define NWCM_ERROR_BASE 0xffff9000 #define NWCM_ERROR_CODE(code) ((s32)(NWCM_ERROR_BASE|(code))) enum { NWCM_ERR_PARAM = NWCM_ERROR_CODE(1), /* Parameter error */ NWCM_ERR_INIT = NWCM_ERROR_CODE(2), /* Cannot run because it is in initialized state */ NWCM_ERR_FINISH = NWCM_ERROR_CODE(3), /* Cannot run because it is in terminated state */ NWCM_ERR_CONFVER = NWCM_ERROR_CODE(4), /* Setting version error */ NWCM_ERR_STATE = NWCM_ERROR_CODE(5), /* State error */ NWCM_ERR_EXIST = NWCM_ERROR_CODE(6), /* Already created */ NWCM_ERR_NOMEM = NWCM_ERROR_CODE(7), /* Insufficient memory */ NWCM_ERR_TIMEOUT = NWCM_ERROR_CODE(8), /* timeout */ NWCM_ERR_NONE = 0 /* Normal end */ }; /* Please see man pages for details */ #define NWCM_MEM_BASE 0x00050000 #define NWCM_MEM_NAME(name) ((s32)(NWCM_MEM_BASE|(name))) enum { NWCM_MEM_INSTANCE = NWCM_MEM_NAME(1) }; /* Please see man pages for details */ enum { NWCM_STATE_INIT = 0, /* Initial state */ NWCM_STATE_WAIT_LINKUP, /* Wait for association to AP */ NWCM_STATE_ACTIVE, /* Connection completed state */ NWCM_STATE_ABORT, /* Cancel association */ NWCM_STATE_MORIBUND /* Disconnecting */ }; /*---------------------------------------------------------------------------* * Types/Declarations *---------------------------------------------------------------------------*/ #define NWCM_MAC_LEN 6 /* Please see man pages for details */ typedef struct NWCMProtocolList { u16 protocol; /* IP, ARP, etc. */ NNETInstance *upper_ins; /* Upper instance */ NOSMessageQueueId mq_receive; /* Queue to insert packet when above protocol is received */ } NWCMProtocolList; /* Please see man pages for details */ typedef struct NWCMCommonConfig { u16 vendor; /* NWCM_VENDOR_NINTENDO */ u16 version; /* NWCM_COMMON_CONF_VERSION */ /* No arguments */ } NWCMCommonConfig; /* Please see man pages for details */ /* AP authentication modes */ #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 encryption mode type */ #define NWCM_WEPMODE_NONE WCM_WEPMODE_NONE /* No encryption */ #define NWCM_WEPMODE_40 WCM_WEPMODE_40 /* RC4 (40-bit) encryption mode */ #define NWCM_WEPMODE_104 WCM_WEPMODE_104 /* RC4 (104-bit) encryption mode */ #define NWCM_WEPMODE_128 WCM_WEPMODE_128 /* RC4 (128-bit) encryption mode */ #define NWCM_SIZE_WEPKEY WCM_WEP_SIZE /* WEP key length */ typedef struct NWCMWepDesc { u8 mode; /* WEP encryption mode ( WCM_WEPMODE_* ) */ u8 keyId; /*/ WEP key ID (0 to 3) */ u8 key[NWCM_SIZE_WEPKEY]; /* WEP key data string [20 * 4 bytes] */ } NWCMWepDesc; /* Please see man pages for details */ #define NWCM_BSSID_SIZE WCM_BSSID_SIZE /* BSSID size */ #define NWCM_ESSID_SIZE WCM_ESSID_SIZE /* ESSID size */ 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; /* Please see man pages for details */ #define NWCM_PROTOCOL_NUM 8 /* ARP, RARP, IP, PPPoE Discovery, PPPoE Session */ #define NWCM_UPPER_NUM 2 /* Number of upper layers */ #define NWCM_MQ_NUM 16 /* Size of queue to pass to upper layers */ #define NWCM_MAX_SEND_LEN 1600 typedef struct NWCMMessage { NOSMessageQueue mq; /* Receive queue for upper layers */ NOSMessage mqarray[NWCM_MQ_NUM]; /* Receive queue instance for upper layers */ } NWCMMessage; typedef struct NWCMInstance { NNETInstance ins; /* Instance information common to all layers */ NWCMInstanceConfig config; /* Instance-specific settings */ NWCMProtocolList upper_protocol[NWCM_PROTOCOL_NUM]; /* Upper protocol and message queue for sending */ s32 upper_protocol_count; NWCMMessage upper_mq[NWCM_UPPER_NUM]; /* Receive queue for upper layers */ s32 upper_ins_count; s32 state; u8 macaddr[NWCM_MAC_LEN]; /* Local MAC address */ u8 sendBuf[NWCM_MAX_SEND_LEN]; /* Send buffer */ } NWCMInstance; /* Get NNETInstance from WCM instance */ NN_INLINE NNETInstance *NWCM_GetNNETInstance(NWCMInstance *wcm_ins) { return (NNETInstance *)wcm_ins; } /* Get WCM instance from NNETInstance */ 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