source: azure_iot_hub_f767zi/trunk/azure_iot_sdk/provisioning_client/inc/azure_prov_client/prov_transport.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 2.5 KB
Line 
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#ifndef PROV_TRANSPORT_H
5#define PROV_TRANSPORT_H
6
7#include "umock_c/umock_c_prod.h"
8#include "azure_macro_utils/macro_utils.h"
9#include "azure_c_shared_utility/shared_util_options.h"
10#include "azure_c_shared_utility/buffer_.h"
11#include "azure_prov_client/prov_client_const.h"
12
13#ifdef __cplusplus
14extern "C" {
15#include <cstdint>
16#include <cstdlib>
17#else
18#include <stdbool.h>
19#include <stdint.h>
20#include <stdlib.h>
21#endif /* __cplusplus */
22
23 struct PROV_DEVICE_TRANSPORT_PROVIDER_TAG;
24 typedef struct PROV_DEVICE_TRANSPORT_PROVIDER_TAG PROV_DEVICE_TRANSPORT_PROVIDER;
25
26 typedef void* PROV_DEVICE_TRANSPORT_HANDLE;
27
28#define TRANSPORT_HSM_TYPE_VALUES \
29 TRANSPORT_HSM_TYPE_TPM, \
30 TRANSPORT_HSM_TYPE_X509, \
31 TRANSPORT_HSM_TYPE_SYMM_KEY
32
33 MU_DEFINE_ENUM_WITHOUT_INVALID(TRANSPORT_HSM_TYPE, TRANSPORT_HSM_TYPE_VALUES);
34
35#define PROV_DEVICE_TRANSPORT_RESULT_VALUES \
36 PROV_DEVICE_TRANSPORT_RESULT_OK, \
37 PROV_DEVICE_TRANSPORT_RESULT_UNAUTHORIZED, \
38 PROV_DEVICE_TRANSPORT_RESULT_ERROR
39
40 MU_DEFINE_ENUM_WITHOUT_INVALID(PROV_DEVICE_TRANSPORT_RESULT, PROV_DEVICE_TRANSPORT_RESULT_VALUES);
41
42 // Snippit from RFC 7231 https://tools.ietf.org/html/rfc7231
43 // The value of this field can be either an HTTP - date or a number of
44 // seconds to delay after the response is received.
45
46 // Retry - After = HTTP - date / delay - seconds
47
48 // A delay - seconds value is a non - negative decimal integer, representing
49 // time in seconds.
50
51 // delay - seconds = 1 * DIGIT
52 // Two examples of its use are
53
54 // Retry-After: Fri, 31 Dec 1999 23 : 59 : 59 GMT
55 // Retry-After : 120
56 static inline uint32_t parse_retry_after_value(const char* retry_after)
57 {
58 uint32_t result = PROV_GET_THROTTLE_TIME;
59 if (retry_after != NULL)
60 {
61 // Is the retry after a number
62 if (retry_after[0] >= 0x30 && retry_after[0] <= 0x39)
63 {
64 result = atol(retry_after);
65 if (result < PROV_GET_THROTTLE_TIME || result > MAX_PROV_GET_THROTTLE_TIME)
66 {
67 result = PROV_GET_THROTTLE_TIME;
68 }
69 }
70 // Will need to parse the retry after for date information
71 }
72 return result;
73 }
74#ifdef __cplusplus
75}
76#endif /* __cplusplus */
77
78#endif // PROV_TRANSPORT
Note: See TracBrowser for help on using the repository browser.