1. Add DPC protocol and DpcLib library in MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Impl.h
1 /** @file
2
3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 Mtftp4Impl.h
15
16 Abstract:
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>
32
33 #include <Protocol/Udp4.h>
34 #include <Protocol/Mtftp4.h>
35
36 #include <Library/DebugLib.h>
37 #include <Library/UefiDriverEntryPoint.h>
38 #include <Library/UefiBootServicesTableLib.h>
39 #include <Library/UefiLib.h>
40 #include <Library/BaseLib.h>
41 #include <Library/UdpIoLib.h>
42 #include <Library/MemoryAllocationLib.h>
43 #include <Library/BaseMemoryLib.h>
44
45 typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;
46 typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
47
48 #include "Mtftp4Driver.h"
49 #include "Mtftp4Option.h"
50 #include "Mtftp4Support.h"
51
52 enum {
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
67 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
89 struct _MTFTP4_PROTOCOL {
90 UINT32 Signature;
91 NET_LIST_ENTRY Link;
92 EFI_MTFTP4_PROTOCOL Mtftp4;
93
94 INTN State;
95 BOOLEAN Indestory;
96
97 MTFTP4_SERVICE *Service;
98 EFI_HANDLE Handle;
99
100 EFI_MTFTP4_CONFIG_DATA Config;
101
102 //
103 // Operation parameters: token and requested options.
104 //
105 EFI_MTFTP4_TOKEN *Token;
106 MTFTP4_OPTION RequestOption;
107 UINT16 Operation;
108
109 //
110 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains
111 // holes in the file
112 //
113 UINT16 BlkSize;
114 UINT16 LastBlock;
115 NET_LIST_ENTRY Blocks;
116
117 //
118 // The server's communication end point: IP and two ports. one for
119 // initial request, one for its selected port.
120 //
121 IP4_ADDR ServerIp;
122 UINT16 ListeningPort;
123 UINT16 ConnectedPort;
124 IP4_ADDR Gateway;
125 UDP_IO_PORT *UnicastPort;
126
127 //
128 // Timeout and retransmit status
129 //
130 NET_BUF *LastPacket;
131 UINT32 PacketToLive;
132 UINT32 CurRetry;
133 UINT32 MaxRetry;
134 UINT32 Timeout;
135
136 //
137 // Parameter used by RRQ's multicast download.
138 //
139 IP4_ADDR McastIp;
140 UINT16 McastPort;
141 BOOLEAN Master;
142 UDP_IO_PORT *McastUdpPort;
143 };
144
145 typedef struct {
146 EFI_MTFTP4_PACKET **Packet;
147 UINT32 *PacketLen;
148 EFI_STATUS Status;
149 } MTFTP4_GETINFO_STATE;
150
151 VOID
152 Mtftp4CleanOperation (
153 IN MTFTP4_PROTOCOL *Instance,
154 IN EFI_STATUS Result
155 );
156
157 EFI_STATUS
158 Mtftp4WrqStart (
159 IN MTFTP4_PROTOCOL *Instance,
160 IN UINT16 Operation
161 );
162
163 EFI_STATUS
164 Mtftp4RrqStart (
165 IN MTFTP4_PROTOCOL *Instance,
166 IN UINT16 Operation
167 );
168
169 #define MTFTP4_SERVICE_FROM_THIS(a) \
170 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)
171
172 #define MTFTP4_PROTOCOL_FROM_THIS(a) \
173 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)
174
175 extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;
176 #endif