Ip4Option.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /** @file
  2. IP4 option support routines.
  3. Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __EFI_IP4_OPTION_H__
  7. #define __EFI_IP4_OPTION_H__
  8. #define IP4_OPTION_EOP 0
  9. #define IP4_OPTION_NOP 1
  10. #define IP4_OPTION_LSRR 131 // Loss source and record routing, 10000011
  11. #define IP4_OPTION_SSRR 137 // Strict source and record routing, 10001001
  12. #define IP4_OPTION_RR 7 // Record routing, 00000111
  13. #define IP4_OPTION_COPY_MASK 0x80
  14. /**
  15. Validate the IP4 option format for both the packets we received
  16. and will transmit. It will compute the ICMP error message fields
  17. if the option is malformatted. But this information isn't used.
  18. @param[in] Option The first byte of the option
  19. @param[in] OptionLen The length of the whole option
  20. @param[in] Rcvd The option is from the packet we received if TRUE,
  21. otherwise the option we wants to transmit.
  22. @retval TRUE The option is properly formatted
  23. @retval FALSE The option is malformatted
  24. **/
  25. BOOLEAN
  26. Ip4OptionIsValid (
  27. IN UINT8 *Option,
  28. IN UINT32 OptionLen,
  29. IN BOOLEAN Rcvd
  30. );
  31. /**
  32. Copy the option from the original option to buffer. It
  33. handles the details such as:
  34. 1. whether copy the single IP4 option to the first/non-first
  35. fragments.
  36. 2. Pad the options copied over to aligned to 4 bytes.
  37. @param[in] Option The original option to copy from
  38. @param[in] OptionLen The length of the original option
  39. @param[in] FirstFragment Whether it is the first fragment
  40. @param[in, out] Buf The buffer to copy options to. NULL
  41. @param[in, out] BufLen The length of the buffer
  42. @retval EFI_SUCCESS The options are copied over
  43. @retval EFI_BUFFER_TOO_SMALL Buf is NULL or BufLen provided is too small.
  44. **/
  45. EFI_STATUS
  46. Ip4CopyOption (
  47. IN UINT8 *Option,
  48. IN UINT32 OptionLen,
  49. IN BOOLEAN FirstFragment,
  50. IN OUT UINT8 *Buf OPTIONAL,
  51. IN OUT UINT32 *BufLen
  52. );
  53. #endif