📄 net.h
字号:
#ifndef NET_H
#define NET_H
/************************************************************************
*
* NET.h
*
* The 'NET' module defines common constants, types, macros atc.
* to be used in the net-subsystem.
*
*
* ######################################################################
*
* Copyright (c) 1999-2000 MIPS Technologies, Inc. All rights reserved.
*
* Unpublished rights reserved under the Copyright Laws of the United States of
* America.
*
* This document contains information that is proprietary to MIPS Technologies,
* Inc. ("MIPS Technologies"). Any copying, modifying or use of this information
* (in whole or in part) which is not expressly permitted in writing by MIPS
* Technologies or a contractually-authorized third party is strictly
* prohibited. At a minimum, this information is protected under unfair
* competition laws and the expression of the information contained herein is
* protected under federal copyright laws. Violations thereof may result in
* criminal penalties and fines.
* MIPS Technologies or any contractually-authorized third party reserves the
* right to change the information contained in this document to improve
* function, design or otherwise. MIPS Technologies does not assume any
* liability arising out of the application or use of this information. Any
* license under patent rights or any other intellectual property rights owned
* by MIPS Technologies or third parties shall be conveyed by MIPS Technologies
* or any contractually-authorized third party in a separate license agreement
* between the parties.
* The information contained in this document constitutes one or more of the
* following: commercial computer software, commercial computer software
* documentation or other commercial items. If the user of this information, or
* any related documentation of any kind, including related technical data or
* manuals, is an agency, department, or other entity of the United States
* government ("Government"), the use, duplication, reproduction, release,
* modification, disclosure, or transfer of this information, or any related
* documentation of any kind, is restricted in accordance with Federal
* Acquisition Regulation 12.212 for civilian agencies and Defense Federal
* Acquisition Regulation Supplement 227.7202 for military agencies. The use of
* this information by the Government is further restricted in accordance with
* the terms of the license agreement(s) and/or applicable contract terms and
* conditions covering this information from MIPS Technologies or any
* contractually-authorized third party.
*
************************************************************************/
/************************************************************************
* Include files
************************************************************************/
#include <sysdefs.h>
#include <syscon_api.h>
/************************************************************************
* Macro definitions
*************************************************************************/
// #define NET_DEBUG 1
#define get1( src, dest ) { *(UINT8*)&dest = *(UINT8*)src++ ; }
#define get2( src, dest ) { *(UINT8*)&dest = *(UINT8*)src++ ; \
*((UINT8*)&dest+1) = *(UINT8*)src++ ; }
#define get4( src, dest ) { *(UINT8*)&dest = *(UINT8*)src++ ; \
*((UINT8*)&dest+1) = *(UINT8*)src++ ; \
*((UINT8*)&dest+2) = *(UINT8*)src++ ; \
*((UINT8*)&dest+3) = *(UINT8*)src++ ; }
#define get6( src, dest ) { *(UINT8*)&dest = *(UINT8*)src++ ; \
*((UINT8*)&dest+1) = *(UINT8*)src++ ; \
*((UINT8*)&dest+2) = *(UINT8*)src++ ; \
*((UINT8*)&dest+3) = *(UINT8*)src++ ; \
*((UINT8*)&dest+4) = *(UINT8*)src++ ; \
*((UINT8*)&dest+5) = *(UINT8*)src++ ; }
#define put1( src, dest ) { *(UINT8*)dest++ = *(UINT8*)&src ; }
#define put2( src, dest ) { *(UINT8*)dest++ = *(UINT8*)&src ; \
*(UINT8*)dest++ = *((UINT8*)&src+1) ; }
#define put4( src, dest ) { *(UINT8*)dest++ = *(UINT8*)&src ; \
*(UINT8*)dest++ = *((UINT8*)&src+1) ; \
*(UINT8*)dest++ = *((UINT8*)&src+2) ; \
*(UINT8*)dest++ = *((UINT8*)&src+3) ; }
#define put6( src, dest ) { *(UINT8*)dest++ = *(UINT8*)&src ; \
*(UINT8*)dest++ = *((UINT8*)&src+1) ; \
*(UINT8*)dest++ = *((UINT8*)&src+2) ; \
*(UINT8*)dest++ = *((UINT8*)&src+3) ; \
*(UINT8*)dest++ = *((UINT8*)&src+4) ; \
*(UINT8*)dest++ = *((UINT8*)&src+5) ; }
#define IF_ERROR( completion, function ) \
{ \
completion = function ; \
if ( completion != OK ) \
{ \
return( completion ) ; \
} \
}
#define IF_UPPER( completion, value, upper ) \
{ \
if ( value >= upper ) \
{ \
return( completion ) ; \
} \
}
/************************************************************************
* Parameter definitions
*************************************************************************/
/************************************************************************
* NET public variables:
*************************************************************************/
extern UINT32 net_last_error ;
extern char net_diag_msg[160] ;
/************************************************************************
* NET general services:
*************************************************************************/
/************************************************************************
*
* NET_gettime
* Description :
* -------------
* Get number of seconds since 1.1.1970.
*
*
* Parameters :
* ------------
* *time, OUT, user defined variable to return the time
*
*
* Return values :
* ---------------
* 'OK'
*
************************************************************************/
UINT32 NET_gettime( UINT32 *time ) ;
/************************************************************************
*
* NET_checksum
* Description :
* -------------
* Return 16-bit one's complement of 16-bit one's complement sum.
*
*
* Parameters :
* ------------
* 'pw', IN, Pointer for start of segment
* 'words', IN, Number of 16-bit words in segment
*
*
* Return values :
* ---------------
* 'IP-header checksum'
*
************************************************************************/
UINT16 NET_checksum( UINT16 *pw, int words ) ;
/************************************************************************
*
* NET_APPL_init
* Description :
* -------------
* Initialize the net applications
*
*
* Parameters :
* ------------
* -
*
*
* Return values :
* ---------------
* 'OK'(=0)
*
************************************************************************/
UINT32 NET_APPL_init( void );
#endif /* #ifndef NET_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -