⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net_tftpc.c

📁 MIPS YAMON, a famous monitor inc. source, make file and PDF manuals.
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************************************ * *      NET_TFTPC.c * *      The 'NET_TFTPC' module implements the TFTP client application, *      which provides services to read a file by use of the *      TFTP-protocol. * * ###################################################################### * * mips_start_of_legal_notice *  * Copyright (c) 2004 MIPS Technologies, Inc. All rights reserved. * * * Unpublished rights (if any) reserved under the copyright laws of the * United States of America and other countries. * * This code is proprietary to MIPS Technologies, Inc. ("MIPS * Technologies"). Any copying, reproducing, modifying or use of this code * (in whole or in part) that is not expressly permitted in writing by MIPS * Technologies or an authorized third party is strictly prohibited. At a * minimum, this code is protected under unfair competition and copyright * laws. Violations thereof may result in criminal penalties and fines. * * MIPS Technologies reserves the right to change this code to improve * function, design or otherwise. MIPS Technologies does not assume any * liability arising out of the application or use of this code, or of any * error or omission in such code. Any warranties, whether express, * statutory, implied or otherwise, including but not limited to the implied * warranties of merchantability or fitness for a particular purpose, are * excluded. Except as expressly provided in any written license agreement * from MIPS Technologies or an authorized third party, the furnishing of * this code does not give recipient any license to any intellectual * property rights, including any patent rights, that cover this code. * * This code shall not be exported, reexported, transferred, or released, * directly or indirectly, in violation of the law of any country or * international law, regulation, treaty, Executive Order, statute, * amendments or supplements thereto. Should a conflict arise regarding the * export, reexport, transfer, or release of this code, the laws of the * United States of America shall be the governing law. * * This code constitutes one or more of the following: commercial computer * software, commercial computer software documentation or other commercial * items. If the user of this code, 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 code, 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 code 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 code from MIPS Technologies or an authorized * third party. * * * *  * mips_end_of_legal_notice *  * ************************************************************************//************************************************************************ *      Include files ************************************************************************///#define NET_DEBUG 1#include <string.h>#include <stdio.h>#include <sysdefs.h>#include <syserror.h>#include <sysdev.h>#include <syscon_api.h>#include <io_api.h>#include <flash_api.h>/* net stuff */#include <net_api.h>#include "net.h"#include "net_mac.h"#include "net_ip.h"#include "net_udp.h"#include "net_tftpc.h"/************************************************************************ *      Definitions ************************************************************************//************************************************************************ *      Public variables ************************************************************************//************************************************************************ *      Static variables ************************************************************************//* Global state of TFTPC */static UINT32 NET_TFTPC_state = TFTPC_STATE_CLOSED ;/* SAP */static t_tftpc_sap_context sap_context ;/************************************************************************ *      Static function prototypes ************************************************************************/#ifdef NET_DEBUGstaticvoid NET_TFTPC_dumpcontext( void ) ;#endif/************************************************************************ * *                          NET_TFTPC_receive_ack *  Description : *  ------------- *  This function is registered in the UDP-module and linked with a *  unique UDP-'port', idnetifying our SAP. This allows the UDP to call *  us back with an reference to the received frame, *  containing a TFTP-frame. * * * *  Parameters : *  ------------ *  'src_ip_adr':  senders IP-address in BE-format *  'src_port':    senders UDP-port in BE-format *  'src_mac_adr': senders MAC-address *  'udp_sp_hd':   UDP defined handle, identifying our SAP (i.e. port) *  'length':      length of received ethernet frame *  'data':        pointer for received ethernet frame (in driver's space) * * *  Return values : *  --------------- *  'ERROR_NET_TFTPC_SAP_ERROR_STATE' *  'ERROR_NET_TFTPC_INVALID_TID' *  'ERROR_NET_TFTP_FILE_TOO_BIG' *  'ERROR_NET_TFTPC_INVALID_BLOCK_NUMBER' *  'OK' * ************************************************************************/staticUINT32 NET_TFTPC_receive_ack(                           UINT32     src_ip_adr,  /* IP BE-format   */                          UINT16     src_port,    /* port BE-format */                          t_mac_addr *src_mac_adr,/* MAC            */                          UINT32     udp_sp_hd,   /* handle of open */                          UINT32     length,      /* total length   */                          UINT8      *data     ); /* start of frame *//************************************************************************ * *                          NET_TFTPC_receive_data_block *  Description : *  ------------- *  This function is registered in the UDP-module and linked with a *  unique UDP-'port', idnetifying our SAP. This allows the UDP to call *  us back with an reference to the received frame, *  containing a TFTP-frame. * * * *  Parameters : *  ------------ *  'src_ip_adr':  senders IP-address in BE-format *  'src_port':    senders UDP-port in BE-format *  'src_mac_adr': senders MAC-address *  'udp_sp_hd':   UDP defined handle, identifying our SAP (i.e. port) *  'length':      length of received ethernet frame *  'data':        pointer for received ethernet frame (in driver's space) * * *  Return values : *  --------------- *  'ERROR_NET_TFTPC_SAP_ERROR_STATE' *  'ERROR_NET_TFTPC_INVALID_TID' *  'ERROR_NET_TFTP_FILE_TOO_BIG' *  'ERROR_NET_TFTPC_INVALID_BLOCK_NUMBER' *  'OK' * ************************************************************************/staticUINT32 NET_TFTPC_receive_data_block(                           UINT32     src_ip_adr,  /* IP BE-format   */                          UINT16     src_port,    /* port BE-format */                          t_mac_addr *src_mac_adr,/* MAC            */                          UINT32     udp_sp_hd,   /* handle of open */                          UINT32     length,      /* total length   */                          UINT8      *data     ); /* start of frame *//************************************************************************ * *                          NET_TFTPC_receive_data_byte *  Description : *  ------------- *  This function is registered in the UDP-module and linked with a  *  unique UDP-'port', idnetifying our SAP. This allows the UDP to call  *  us back with an reference to the received frame,  *  containing a TFTP-frame. * * * *  Parameters : *  ------------ *  'src_ip_adr':  senders IP-address in BE-format *  'src_port':    senders UDP-port in BE-format *  'src_mac_adr': senders MAC-address *  'udp_sp_hd':   UDP defined handle, identifying our SAP (i.e. port) *  'length':      length of received ethernet frame *  'data':        pointer for received ethernet frame (in driver's space) * * *  Return values : *  --------------- *  'ERROR_NET_TFTPC_SAP_ERROR_STATE' *  'ERROR_NET_TFTPC_INVALID_TID' *  'ERROR_NET_TFTP_FILE_TOO_BIG' *  'ERROR_NET_TFTPC_INVALID_BLOCK_NUMBER' *  'ERROR_NET_TFTPC_CONGESTION' *  'OK'  * ************************************************************************/staticUINT32 NET_TFTPC_receive_data_byte(                           UINT32     src_ip_adr,  /* IP BE-format   */                          UINT16     src_port,    /* port BE-format */                          t_mac_addr *src_mac_adr,/* MAC            */                          UINT32     udp_sp_hd,   /* handle of open */                          UINT32     length,      /* total length   */                          UINT8      *data     ); /* start of frame *//************************************************************************ * *                          NET_TFTPC_init_sap *  Description : *  ------------- *  Initialize the TFTPC SAP context. * * *  Parameters : *  ------------ *  - * * *  Return values : *  --------------- *  'OK'(=0), successfull initialization * ************************************************************************/staticUINT32 NET_TFTPC_init_sap( t_tftpc_sap_context *context ) ;/************************************************************************ * *                          NET_TFTPC_reset_sap *  Description : *  ------------- *  Reset the TFTPC SAP context. * * *  Parameters : *  ------------ *  - * * *  Return values : *  --------------- *  'OK'(=0), successfull initialization I************************************************************************/staticUINT32 NET_TFTPC_reset_sap( t_tftpc_sap_context *context,                            t_udp_usr_receive   rec ) ;/************************************************************************ * *                          NET_TFTPC_sendDATA *  Description : *  ------------- *  Send 'DATA' of this SAP context. * * *  Parameters : *  ------------ *  - * * *  Return values : *  --------------- *  'OK'(=0), *************************************************************************/staticUINT32 NET_TFTPC_sendDATA( t_tftpc_sap_context *context ) ;/************************************************************************ * *                          NET_TFTPC_sendRRQ *  Description : *  ------------- *  Send 'RRQ' of this SAP context. * * *  Parameters : *  ------------ *  - * * *  Return values : *  --------------- *  'OK'(=0),  *************************************************************************/staticUINT32 NET_TFTPC_sendRRQ( t_tftpc_sap_context *context ) ;/************************************************************************ * *                          NET_TFTPC_sendWRQ *  Description : *  ------------- *  Send 'WRQ' of this SAP context. * * *  Parameters : *  ------------ *  - * * *  Return values : *  --------------- *  'OK'(=0), *************************************************************************/staticUINT32 NET_TFTPC_sendWRQ( t_tftpc_sap_context *context ) ;/************************************************************************ * *                          NET_TFTPC_sendACK *  Description : *  ------------- *  Send 'ACK' of this SAP context. * * *  Parameters : *  ------------ *  - * * *  Return values : *  --------------- *  'OK'(=0),  *************************************************************************/staticUINT32 NET_TFTPC_sendACK( t_tftpc_sap_context *context ) ;/************************************************************************ * *                          NET_TFTPC_unknownTID *  Description : *  ------------- *  Send 'ERROR' packet, cause = 'unknown TID' * * *  Parameters : *  ------------ *  - * * *  Return values : *  --------------- *  'OK'(=0), *************************************************************************/staticUINT32 NET_TFTPC_unknownTID(                     UINT32     dst_ip_adr, /* dest. ip address (BE) */                     UINT16     dst_port,   /* dest. port (BE)       */                     UINT32     sp_hd   ) ; /* handle from 'open'    */#if 0 /* currently not called *//************************************************************************ * *                          NET_TFTPC_sendERROR *  Description : *  ------------- *  Send 'ERROR' of this SAP context. * * *  Parameters : *  ------------ *  - * * *  Return values :

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -