5 Mtftp4 Implementation, it supports the following RFCs:
6 RFC1350 - THE TFTP PROTOCOL (REVISION 2)
7 RFC2090 - TFTP Multicast Option
8 RFC2347 - TFTP Option Extension
9 RFC2348 - TFTP Blocksize Option
10 RFC2349 - TFTP Timeout Interval and Transfer Size Options
12 Copyright (c) 2006 - 2007, Intel Corporation<BR>
13 All rights reserved. This program and the accompanying materials
14 are licensed and made available under the terms and conditions of the BSD License
15 which accompanies this distribution. The full text of the license may be found at
16 http://opensource.org/licenses/bsd-license.php<BR>
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 #ifndef __EFI_MTFTP4_IMPL_H__
25 #define __EFI_MTFTP4_IMPL_H__
29 #include <Protocol/Udp4.h>
30 #include <Protocol/Mtftp4.h>
32 #include <Library/DebugLib.h>
33 #include <Library/UefiBootServicesTableLib.h>
34 #include <Library/UdpIoLib.h>
36 extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate
;
38 typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE
;
39 typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL
;
41 #include "Mtftp4Driver.h"
42 #include "Mtftp4Option.h"
43 #include "Mtftp4Support.h"
47 /// Some constant value of Mtftp service.
50 MTFTP4_SERVICE_SIGNATURE
= SIGNATURE_32 ('T', 'F', 'T', 'P'),
51 MTFTP4_PROTOCOL_SIGNATURE
= SIGNATURE_32 ('t', 'f', 't', 'p'),
53 MTFTP4_DEFAULT_SERVER_PORT
= 69,
54 MTFTP4_DEFAULT_TIMEOUT
= 3,
55 MTFTP4_DEFAULT_RETRY
= 5,
56 MTFTP4_DEFAULT_BLKSIZE
= 512,
57 MTFTP4_TIME_TO_GETMAP
= 5,
59 MTFTP4_STATE_UNCONFIGED
= 0,
60 MTFTP4_STATE_CONFIGED
,
62 } MTFTP4_SERVICE_CONST_VALUE
;
65 /// Mtftp service block
67 struct _MTFTP4_SERVICE
{
69 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
76 EFI_EVENT Timer
; ///< Ticking timer for all the MTFTP clients
77 EFI_EVENT TimerToGetMap
;
79 EFI_HANDLE Controller
;
83 // This UDP child is used to keep the connection between the UDP
84 // and MTFTP, so MTFTP will be notified when UDP is uninstalled.
86 UDP_IO_PORT
*ConnectUdp
;
91 EFI_MTFTP4_PACKET
**Packet
;
94 } MTFTP4_GETINFO_STATE
;
96 struct _MTFTP4_PROTOCOL
{
99 EFI_MTFTP4_PROTOCOL Mtftp4
;
104 MTFTP4_SERVICE
*Service
;
107 EFI_MTFTP4_CONFIG_DATA Config
;
110 // Operation parameters: token and requested options.
112 EFI_MTFTP4_TOKEN
*Token
;
113 MTFTP4_OPTION RequestOption
;
117 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains
125 // The server's communication end point: IP and two ports. one for
126 // initial request, one for its selected port.
129 UINT16 ListeningPort
;
130 UINT16 ConnectedPort
;
132 UDP_IO_PORT
*UnicastPort
;
135 // Timeout and retransmit status
144 // Parameter used by RRQ's multicast download.
149 UDP_IO_PORT
*McastUdpPort
;
151 MTFTP4_GETINFO_STATE GetInfoState
;
155 Clean up the MTFTP session to get ready for new operation.
157 @param Instance The MTFTP session to clean up
158 @param Result The result to return to the caller who initiated
162 Mtftp4CleanOperation (
163 IN OUT MTFTP4_PROTOCOL
*Instance
,
168 Start the MTFTP session for upload.
170 It will first init some states, then send the WRQ request packet,
171 and start receiving the packet.
173 @param Instance The MTFTP session
174 @param Operation Redundant parameter, which is always
175 EFI_MTFTP4_OPCODE_WRQ here.
177 @retval EFI_SUCCESS The upload process has been started.
178 @retval Others Failed to start the upload.
183 IN MTFTP4_PROTOCOL
*Instance
,
188 Start the MTFTP session to download.
190 It will first initialize some of the internal states then build and send a RRQ
191 reqeuest packet, at last, it will start receive for the downloading.
193 @param Instance The Mtftp session
194 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ
195 or EFI_MTFTP4_OPCODE_DIR.
197 @retval EFI_SUCCESS The mtftp download session is started.
198 @retval Others Failed to start downloading.
203 IN MTFTP4_PROTOCOL
*Instance
,
207 #define MTFTP4_SERVICE_FROM_THIS(a) \
208 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)
210 #define MTFTP4_PROTOCOL_FROM_THIS(a) \
211 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)