]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Option.h
CommitLineData
83cbd279 1/** @file\r
dab714aa 2 Routines to process MTFTP4 options.\r
d1102dba
LG
3\r
4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
83cbd279 6\r
83cbd279 7**/\r
8\r
dab714aa 9\r
83cbd279 10#ifndef __EFI_MTFTP4_OPTION_H__\r
11#define __EFI_MTFTP4_OPTION_H__\r
12\r
6c047cfa 13#define MTFTP4_SUPPORTED_OPTIONS 5\r
f6b7393c 14#define MTFTP4_OPCODE_LEN 2\r
15#define MTFTP4_ERRCODE_LEN 2\r
16#define MTFTP4_BLKNO_LEN 2\r
17#define MTFTP4_DATA_HEAD_LEN 4\r
dab714aa 18\r
f6b7393c 19#define MTFTP4_BLKSIZE_EXIST 0x01\r
20#define MTFTP4_TIMEOUT_EXIST 0x02\r
21#define MTFTP4_TSIZE_EXIST 0x04\r
22#define MTFTP4_MCAST_EXIST 0x08\r
6c047cfa 23#define MTFTP4_WINDOWSIZE_EXIST 0x10\r
83cbd279 24\r
25typedef struct {\r
26 UINT16 BlkSize;\r
6c047cfa 27 UINT16 WindowSize;\r
83cbd279 28 UINT8 Timeout;\r
29 UINT32 Tsize;\r
30 IP4_ADDR McastIp;\r
31 UINT16 McastPort;\r
32 BOOLEAN Master;\r
33 UINT32 Exist;\r
34} MTFTP4_OPTION;\r
35\r
dab714aa 36/**\r
d1102dba
LG
37 Allocate and fill in a array of Mtftp options from the Packet.\r
38\r
dab714aa 39 It first calls Mtftp4FillOption to get the option number, then allocate\r
40 the array, at last, call Mtftp4FillOption again to save the options.\r
41\r
42 @param Packet The packet to parse\r
43 @param PacketLen The length of the packet\r
44 @param OptionCount The number of options in the packet\r
45 @param OptionList The point to get the option array.\r
46\r
47 @retval EFI_INVALID_PARAMETER The parametera are invalid or packet isn't a\r
48 well-formated OACK packet.\r
49 @retval EFI_SUCCESS The option array is build\r
50 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array\r
51\r
52**/\r
83cbd279 53EFI_STATUS\r
54Mtftp4ExtractOptions (\r
dab714aa 55 IN EFI_MTFTP4_PACKET *Packet,\r
56 IN UINT32 PacketLen,\r
57 OUT UINT32 *OptionCount,\r
58 OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL\r
83cbd279 59 );\r
60\r
dab714aa 61/**\r
62 Parse the option in Options array to MTFTP4_OPTION which program\r
63 can access directly.\r
64\r
65 @param Options The option array, which contains addresses of each\r
66 option's name/value string.\r
67 @param Count The number of options in the Options\r
68 @param Request Whether this is a request or OACK. The format of\r
69 multicast is different according to this setting.\r
6c047cfa 70 @param Operation The current performed operation.\r
dab714aa 71 @param MtftpOption The MTFTP4_OPTION for easy access.\r
72\r
73 @retval EFI_INVALID_PARAMETER The option is mal-formated\r
74 @retval EFI_UNSUPPORTED Some option isn't supported\r
75 @retval EFI_SUCCESS The option are OK and has been parsed.\r
76\r
77**/\r
83cbd279 78EFI_STATUS\r
79Mtftp4ParseOption (\r
dab714aa 80 IN EFI_MTFTP4_OPTION *Options,\r
81 IN UINT32 Count,\r
82 IN BOOLEAN Request,\r
6c047cfa 83 IN UINT16 Operation,\r
dab714aa 84 OUT MTFTP4_OPTION *MtftpOption\r
83cbd279 85 );\r
86\r
dab714aa 87/**\r
88 Parse the options in the OACK packet to MTFTP4_OPTION which program\r
89 can access directly.\r
90\r
91 @param Packet The OACK packet to parse\r
92 @param PacketLen The length of the packet\r
6c047cfa 93 @param Operation The current performed operation.\r
dab714aa 94 @param MtftpOption The MTFTP_OPTION for easy access.\r
95\r
96 @retval EFI_INVALID_PARAMETER The packet option is mal-formated\r
97 @retval EFI_UNSUPPORTED Some option isn't supported\r
98 @retval EFI_SUCCESS The option are OK and has been parsed.\r
99\r
100**/\r
83cbd279 101EFI_STATUS\r
102Mtftp4ParseOptionOack (\r
dab714aa 103 IN EFI_MTFTP4_PACKET *Packet,\r
104 IN UINT32 PacketLen,\r
6c047cfa 105 IN UINT16 Operation,\r
dab714aa 106 OUT MTFTP4_OPTION *MtftpOption\r
83cbd279 107 );\r
108\r
67a58d0f 109extern CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS];\r
dab714aa 110\r
83cbd279 111#endif\r