]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Option.h
MdeModulePkg: Fix IPv4 double free
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Option.h
CommitLineData
83cbd279 1/** @file\r
3e8c18da 2 IP4 option support routines.\r
3 \r
e5eed7d3
HT
4Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
83cbd279 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
83cbd279 13**/\r
14\r
15#ifndef __EFI_IP4_OPTION_H__\r
16#define __EFI_IP4_OPTION_H__\r
17\r
f6b7393c 18#define IP4_OPTION_EOP 0\r
19#define IP4_OPTION_NOP 1\r
20#define IP4_OPTION_LSRR 131 // Loss source and record routing, 10000011\r
21#define IP4_OPTION_SSRR 137 // Strict source and record routing, 10001001\r
22#define IP4_OPTION_RR 7 // Record routing, 00000111\r
83cbd279 23\r
f6b7393c 24#define IP4_OPTION_COPY_MASK 0x80\r
83cbd279 25\r
2ff29212 26/**\r
27 Validate the IP4 option format for both the packets we received\r
28 and will transmit. It will compute the ICMP error message fields\r
29 if the option is mal-formated. But this information isn't used.\r
30\r
3e8c18da 31 @param[in] Option The first byte of the option\r
32 @param[in] OptionLen The length of the whole option\r
33 @param[in] Rcvd The option is from the packet we received if TRUE,\r
2ff29212 34 otherwise the option we wants to transmit.\r
35\r
36 @retval TRUE The option is properly formatted\r
37 @retval FALSE The option is mal-formated\r
38\r
39**/\r
83cbd279 40BOOLEAN\r
41Ip4OptionIsValid (\r
42 IN UINT8 *Option,\r
2ff29212 43 IN UINT32 OptionLen,\r
83cbd279 44 IN BOOLEAN Rcvd\r
45 );\r
46\r
2ff29212 47/**\r
48 Copy the option from the original option to buffer. It\r
49 handles the details such as:\r
50 1. whether copy the single IP4 option to the first/non-first\r
51 fragments.\r
52 2. Pad the options copied over to aligned to 4 bytes.\r
53\r
3e8c18da 54 @param[in] Option The original option to copy from\r
55 @param[in] OptionLen The length of the original option\r
56 @param[in] FirstFragment Whether it is the first fragment\r
57 @param[in, out] Buf The buffer to copy options to. NULL \r
58 @param[in, out] BufLen The length of the buffer\r
2ff29212 59\r
60 @retval EFI_SUCCESS The options are copied over\r
61 @retval EFI_BUFFER_TOO_SMALL Buf is NULL or BufLen provided is too small.\r
62\r
63**/\r
83cbd279 64EFI_STATUS\r
65Ip4CopyOption (\r
2ff29212 66 IN UINT8 *Option,\r
67 IN UINT32 OptionLen,\r
68 IN BOOLEAN FirstFragment,\r
69 IN OUT UINT8 *Buf, OPTIONAL\r
83cbd279 70 IN OUT UINT32 *BufLen\r
71 );\r
72#endif\r