Mtftp4Option.h 3.7 KB

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