1. Enable Mtftp4Dxe in MdeModulePkg.dsc
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Impl.h
CommitLineData
772db4bb 1/** @file
2
3Copyright (c) 2006 - 2007, Intel Corporation
4All rights reserved. This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 Mtftp4Impl.h
15
16Abstract:
17
18 Mtftp4 Implementation, it supports the following RFCs:
19 RFC1350 - THE TFTP PROTOCOL (REVISION 2)
20 RFC2090 - TFTP Multicast Option
21 RFC2347 - TFTP Option Extension
22 RFC2348 - TFTP Blocksize Option
23 RFC2349 - TFTP Timeout Interval and Transfer Size Options
24
25
26**/
27
28#ifndef __EFI_MTFTP4_IMPL_H__
29#define __EFI_MTFTP4_IMPL_H__
30
31#include <PiDxe.h>\r
32\r
33#include <Protocol/Udp4.h>\r
34#include <Protocol/Mtftp4.h>\r
35\r
36#include <Library/DebugLib.h>\r
37#include <Library/UefiDriverEntryPoint.h>\r
38#include <Library/UefiBootServicesTableLib.h>\r
39#include <Library/UefiLib.h>\r
40#include <Library/BaseLib.h>
41#include <Library/UdpIoLib.h>
42#include <Library/MemoryAllocationLib.h>
43#include <Library/BaseMemoryLib.h>
44
45typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;
46typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
47
48#include "Mtftp4Driver.h"
49#include "Mtftp4Option.h"
50#include "Mtftp4Support.h"
51
52enum {
53 MTFTP4_SERVICE_SIGNATURE = EFI_SIGNATURE_32 ('T', 'F', 'T', 'P'),
54 MTFTP4_PROTOCOL_SIGNATURE = EFI_SIGNATURE_32 ('t', 'f', 't', 'p'),
55
56 MTFTP4_DEFAULT_SERVER_PORT = 69,
57 MTFTP4_DEFAULT_TIMEOUT = 3,
58 MTFTP4_DEFAULT_RETRY = 5,
59 MTFTP4_DEFAULT_BLKSIZE = 512,
60 MTFTP4_TIME_TO_GETMAP = 5,
61
62 MTFTP4_STATE_UNCONFIGED = 0,
63 MTFTP4_STATE_CONFIGED,
64 MTFTP4_STATE_DESTORY,
65};
66
67typedef struct _MTFTP4_SERVICE {
68 UINT32 Signature;
69 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
70
71 BOOLEAN InDestory;
72
73 UINT16 ChildrenNum;
74 NET_LIST_ENTRY Children;
75
76 EFI_EVENT Timer; // Ticking timer for all the MTFTP clients
77 EFI_EVENT TimerToGetMap;
78
79 EFI_HANDLE Controller;
80 EFI_HANDLE Image;
81
82 //
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.
85 //
86 UDP_IO_PORT *ConnectUdp;
87};
88
a5867703 89typedef struct {
90 EFI_MTFTP4_PACKET **Packet;
91 UINT32 *PacketLen;
92 EFI_STATUS Status;
93} MTFTP4_GETINFO_STATE;
94
772db4bb 95typedef struct _MTFTP4_PROTOCOL {
96 UINT32 Signature;
97 NET_LIST_ENTRY Link;
98 EFI_MTFTP4_PROTOCOL Mtftp4;
99
100 INTN State;
101 BOOLEAN Indestory;
102
103 MTFTP4_SERVICE *Service;
104 EFI_HANDLE Handle;
105
106 EFI_MTFTP4_CONFIG_DATA Config;
107
108 //
109 // Operation parameters: token and requested options.
110 //
111 EFI_MTFTP4_TOKEN *Token;
112 MTFTP4_OPTION RequestOption;
113 UINT16 Operation;
114
115 //
116 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains
117 // holes in the file
118 //
119 UINT16 BlkSize;
120 UINT16 LastBlock;
121 NET_LIST_ENTRY Blocks;
122
123 //
124 // The server's communication end point: IP and two ports. one for
125 // initial request, one for its selected port.
126 //
127 IP4_ADDR ServerIp;
128 UINT16 ListeningPort;
129 UINT16 ConnectedPort;
130 IP4_ADDR Gateway;
131 UDP_IO_PORT *UnicastPort;
132
133 //
134 // Timeout and retransmit status
135 //
136 NET_BUF *LastPacket;
137 UINT32 PacketToLive;
138 UINT32 CurRetry;
139 UINT32 MaxRetry;
140 UINT32 Timeout;
141
142 //
143 // Parameter used by RRQ's multicast download.
144 //
145 IP4_ADDR McastIp;
146 UINT16 McastPort;
147 BOOLEAN Master;
148 UDP_IO_PORT *McastUdpPort;
772db4bb 149
a5867703 150 MTFTP4_GETINFO_STATE GetInfoState;
151};
772db4bb 152
153VOID
154Mtftp4CleanOperation (
155 IN MTFTP4_PROTOCOL *Instance,
156 IN EFI_STATUS Result
157 );
158
159EFI_STATUS
160Mtftp4WrqStart (
161 IN MTFTP4_PROTOCOL *Instance,
162 IN UINT16 Operation
163 );
164
165EFI_STATUS
166Mtftp4RrqStart (
167 IN MTFTP4_PROTOCOL *Instance,
168 IN UINT16 Operation
169 );
170
171#define MTFTP4_SERVICE_FROM_THIS(a) \
172 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)
173
174#define MTFTP4_PROTOCOL_FROM_THIS(a) \
175 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)
176
177extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;
178#endif