]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h
3e450101cd1b042d445e0877a9506898b63deada
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Option.h
1 /** @file
2 Routines to process MTFTP4 options.
3
4 Copyright (c) 2006 - 2007, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php<BR>
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15
16 #ifndef __EFI_MTFTP4_OPTION_H__
17 #define __EFI_MTFTP4_OPTION_H__
18
19
20
21 typedef enum {
22 MTFTP4_SUPPORTED_OPTIONS = 4,
23 MTFTP4_OPCODE_LEN = 2,
24 MTFTP4_ERRCODE_LEN = 2,
25 MTFTP4_BLKNO_LEN = 2,
26 MTFTP4_DATA_HEAD_LEN = 4,
27
28 MTFTP4_BLKSIZE_EXIST = 0x01,
29 MTFTP4_TIMEOUT_EXIST = 0x02,
30 MTFTP4_TSIZE_EXIST = 0x04,
31 MTFTP4_MCAST_EXIST = 0x08
32 } MTFTP4_OPTION_CONST_VALUE;
33
34 typedef struct {
35 UINT16 BlkSize;
36 UINT8 Timeout;
37 UINT32 Tsize;
38 IP4_ADDR McastIp;
39 UINT16 McastPort;
40 BOOLEAN Master;
41 UINT32 Exist;
42 } MTFTP4_OPTION;
43
44 /**
45 Allocate and fill in a array of Mtftp options from the Packet.
46
47 It first calls Mtftp4FillOption to get the option number, then allocate
48 the array, at last, call Mtftp4FillOption again to save the options.
49
50 @param Packet The packet to parse
51 @param PacketLen The length of the packet
52 @param OptionCount The number of options in the packet
53 @param OptionList The point to get the option array.
54
55 @retval EFI_INVALID_PARAMETER The parametera are invalid or packet isn't a
56 well-formated OACK packet.
57 @retval EFI_SUCCESS The option array is build
58 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array
59
60 **/
61 EFI_STATUS
62 Mtftp4ExtractOptions (
63 IN EFI_MTFTP4_PACKET *Packet,
64 IN UINT32 PacketLen,
65 OUT UINT32 *OptionCount,
66 OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
67 );
68
69 /**
70 Parse the option in Options array to MTFTP4_OPTION which program
71 can access directly.
72
73 @param Options The option array, which contains addresses of each
74 option's name/value string.
75 @param Count The number of options in the Options
76 @param Request Whether this is a request or OACK. The format of
77 multicast is different according to this setting.
78 @param MtftpOption The MTFTP4_OPTION for easy access.
79
80 @retval EFI_INVALID_PARAMETER The option is mal-formated
81 @retval EFI_UNSUPPORTED Some option isn't supported
82 @retval EFI_SUCCESS The option are OK and has been parsed.
83
84 **/
85 EFI_STATUS
86 Mtftp4ParseOption (
87 IN EFI_MTFTP4_OPTION *Options,
88 IN UINT32 Count,
89 IN BOOLEAN Request,
90 OUT MTFTP4_OPTION *MtftpOption
91 );
92
93 /**
94 Parse the options in the OACK packet to MTFTP4_OPTION which program
95 can access directly.
96
97 @param Packet The OACK packet to parse
98 @param PacketLen The length of the packet
99 @param MtftpOption The MTFTP_OPTION for easy access.
100
101 @retval EFI_INVALID_PARAMETER The packet option is mal-formated
102 @retval EFI_UNSUPPORTED Some option isn't supported
103 @retval EFI_SUCCESS The option are OK and has been parsed.
104
105 **/
106 EFI_STATUS
107 Mtftp4ParseOptionOack (
108 IN EFI_MTFTP4_PACKET *Packet,
109 IN UINT32 PacketLen,
110 OUT MTFTP4_OPTION *MtftpOption
111 );
112
113 extern CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS];
114
115 #endif