]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
MdeModulePkg/DxeHttpLib: Fix the incorrect return status if URI port is invalid
[mirror_edk2.git] / MdeModulePkg / Library / DxeHttpLib / DxeHttpLib.h
1 /** @file
2 Header file for HttpLib.
3
4 Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef _DXE_HTTP_LIB_H_
18 #define _DXE_HTTP_LIB_H_
19
20 #include <Uefi.h>
21 #include <Library/NetLib.h>
22 #include <Library/HttpLib.h>
23 #include <Library/BaseLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/MemoryAllocationLib.h>
26 #include <Library/UefiBootServicesTableLib.h>
27 #include <IndustryStandard/Http11.h>
28 #include <Protocol/HttpUtilities.h>
29
30 #define BIT(x) (1 << x)
31
32 #define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n"
33 #define EMPTY_SPACE " "
34
35 #define NET_IS_HEX_CHAR(Ch) \
36 ((('0' <= (Ch)) && ((Ch) <= '9')) || \
37 (('A' <= (Ch)) && ((Ch) <= 'F')) || \
38 (('a' <= (Ch)) && ((Ch) <= 'f')))
39
40 //
41 // Field index of the HTTP URL parse result.
42 //
43 #define HTTP_URI_FIELD_SCHEME 0
44 #define HTTP_URI_FIELD_AUTHORITY 1
45 #define HTTP_URI_FIELD_PATH 2
46 #define HTTP_URI_FIELD_QUERY 3
47 #define HTTP_URI_FIELD_FRAGMENT 4
48 #define HTTP_URI_FIELD_USERINFO 5
49 #define HTTP_URI_FIELD_HOST 6
50 #define HTTP_URI_FIELD_PORT 7
51 #define HTTP_URI_FIELD_MAX 8
52
53 #define HTTP_URI_PORT_MIN_NUM 0
54 #define HTTP_URI_PORT_MAX_NUM 65535
55
56 //
57 // Structure to store the parse result of a HTTP URL.
58 //
59 typedef struct {
60 UINT32 Offset;
61 UINT32 Length;
62 } HTTP_URL_FILED_DATA;
63
64 typedef struct {
65 UINT16 FieldBitMap;
66 HTTP_URL_FILED_DATA FieldData[HTTP_URI_FIELD_MAX];
67 } HTTP_URL_PARSER;
68
69 typedef enum {
70 UrlParserUrlStart,
71 UrlParserScheme,
72 UrlParserSchemeColon, // ":"
73 UrlParserSchemeColonSlash, // ":/"
74 UrlParserSchemeColonSlashSlash, // "://"
75 UrlParserAuthority,
76 UrlParserAtInAuthority,
77 UrlParserPath,
78 UrlParserQueryStart, // "?"
79 UrlParserQuery,
80 UrlParserFragmentStart, // "#"
81 UrlParserFragment,
82 UrlParserUserInfo,
83 UrlParserHostStart, // "@"
84 UrlParserHost,
85 UrlParserHostIpv6, // "["(Ipv6 address) "]"
86 UrlParserPortStart, // ":"
87 UrlParserPort,
88 UrlParserStateMax
89 } HTTP_URL_PARSE_STATE;
90
91 #endif
92