summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
blob: 0d0ad3d8ffc34b5d5d1196552402d92b73ed6f18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/** @file
Header file for HttpLib.

  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef _DXE_HTTP_LIB_H_
#define _DXE_HTTP_LIB_H_

#include <Uefi.h>
#include <Library/NetLib.h>
#include <Library/HttpLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <IndustryStandard/Http11.h>
#include <Protocol/HttpUtilities.h>

#define BIT(x)  (1 << x)

#define HTTP_VERSION_CRLF_STR  " HTTP/1.1\r\n"
#define EMPTY_SPACE            " "

#define NET_IS_HEX_CHAR(Ch)   \
  ((('0' <= (Ch)) && ((Ch) <= '9')) ||  \
   (('A' <= (Ch)) && ((Ch) <= 'F')) ||  \
   (('a' <= (Ch)) && ((Ch) <= 'f')))

//
// Field index of the HTTP URL parse result.
//
#define   HTTP_URI_FIELD_SCHEME           0
#define   HTTP_URI_FIELD_AUTHORITY        1
#define   HTTP_URI_FIELD_PATH             2
#define   HTTP_URI_FIELD_QUERY            3
#define   HTTP_URI_FIELD_FRAGMENT         4
#define   HTTP_URI_FIELD_USERINFO         5
#define   HTTP_URI_FIELD_HOST             6
#define   HTTP_URI_FIELD_PORT             7
#define   HTTP_URI_FIELD_MAX              8

//
// Structure to store the parse result of a HTTP URL.
//
typedef struct {
  UINT32      Offset;
  UINT32      Length;
} HTTP_URL_FILED_DATA;

typedef struct {
  UINT16                  FieldBitMap;
  HTTP_URL_FILED_DATA     FieldData[HTTP_URI_FIELD_MAX];
} HTTP_URL_PARSER;

typedef enum {
  UrlParserUrlStart,
  UrlParserScheme,
  UrlParserSchemeColon,            // ":"
  UrlParserSchemeColonSlash,       // ":/"
  UrlParserSchemeColonSlashSlash,  // "://"
  UrlParserAuthority,
  UrlParserAtInAuthority,
  UrlParserPath,
  UrlParserQueryStart,    // "?"
  UrlParserQuery,
  UrlParserFragmentStart, // "#"
  UrlParserFragment,
  UrlParserUserInfo,
  UrlParserHostStart,     // "@"
  UrlParserHost,
  UrlParserHostIpv6,      // "["(Ipv6 address) "]"
  UrlParserPortStart,     // ":"
  UrlParserPort,
  UrlParserStateMax
} HTTP_URL_PARSE_STATE;

#endif