1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: nnet_ext.h 4 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 $Rev: 12449 $ 11 *--------------------------------------------------------------------------- 12 13 14 */ 15 16 #ifndef NNET_EXT_H_ 17 #define NNET_EXT_H_ 18 19 #include <nn/net/compatible/nnet.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define NNET_CANCEL_MESSAGE ((void*)0xffffffff) 26 #define NNET_MAX_SEND_LEN 1600 27 #define NNET_MAX_RECV_LEN 1600 28 29 /* Please see man pages for details 30 31 */ 32 33 #define NNET_PROTOCOL_NUM 8 /* ARP, RARP, IP, PPPoE Discovery, PPPoE Session */ 34 35 typedef struct NNETProtocolInfo 36 { 37 u16 protocolId; /* IP, ARP, etc. */ 38 NNETInstance* pUpperNetIns; /* Upper instance */ 39 u32 rxId; /* identification ID when registered (user usage area) */ 40 } NNETProtocolInfo; 41 42 typedef struct NNETProtocolList 43 { 44 NNETProtocolInfo protocols[NNET_PROTOCOL_NUM]; 45 s32 protocol_count; 46 } NNETProtocolList; 47 48 typedef struct NNETEthHeader 49 { 50 u8 dst[NNET_ETH_ALEN]; 51 u8 src[NNET_ETH_ALEN]; 52 u16 type; 53 } NNETEthHeader; 54 55 #define NNET_ETH_HLEN sizeof(NNETEthHeader) 56 57 typedef struct NNETIeeeHeader 58 { 59 u8 dst[NNET_ETH_ALEN]; 60 u8 src[NNET_ETH_ALEN]; 61 u16 length; 62 u8 dsap; /* destination SAP type */ 63 u8 ssap; /* source SAP type */ 64 u8 control; /* control */ 65 u8 id[3]; /* ID */ 66 u16 type; /* type */ 67 } NNETIeeeHeader; 68 69 #define NNET_IEEE_HLEN sizeof(NNETIeeeHeader) 70 71 72 extern const u8 NNETETHAddrBroadcast[NNET_ETH_ALEN]; 73 extern const u8 NNETETHAddrAny[NNET_ETH_ALEN]; 74 75 BOOL NNET_RegisterProtocols(NNETProtocolList* pProtocolList, const u16 protocols[], NNETInstance* pUpperNetIns, u32 rxId); 76 BOOL NNET_UnregisterProtocols(NNETProtocolList* pProtocolList, const NNETInstance* pUpperNetIns, u32* pRxId); 77 NNETProtocolInfo* NNET_GetProtocolInfo(NNETProtocolList* pProtocolList, u16 protocol); 78 79 NOSMessageBuf* NNET_ConvertFrameToMbuf(const u8* dstMac, const u8* srcMac, u16 protocol, const u8* pBody, int bodyLen, u8 tag); 80 s32 NNET_HandleLoopback(NNETProtocolList* pProtocolList, NOSMessageBuf* mbuf, BOOL* bContinue); 81 void NNET_DumpProtocolList(const NNETProtocolList* pProtocolList); 82 void NNET_FreeBuffersInQueue(NOSMessageQueueId mqId); 83 84 void NNET_HandleDixFrameRaw(NNETProtocolList* pProtocolList, const u8* pFrame, int len, u8 tag); 85 void NNET_HandleIeeeFrameRaw(NNETProtocolList* pProtocolList, const u8* pFrame, int len, u8 tag); 86 void NNET_HandleIeeeFrame(NNETProtocolList* pProtocolList, NOSMessageBuf* mbuf); 87 s32 NNET_SendPreProcess(NOSMessageBuf** ppMbuf, u16* pLength, const u8* pSrcMac, const u8* pDstMac); 88 89 90 #ifdef __cplusplus 91 } 92 #endif 93 94 /* NNET_EXT_H_ */ 95 #endif 96