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