IoT managed integrations End Device SDK
Loading...
Searching...
No Matches
iotmi_pal_NetworkTransport.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
3 *
4 * AMAZON PROPRIETARY/CONFIDENTIAL
5 *
6 * You may not use this file except in compliance with the terms and
7 * conditions set forth in the accompanying LICENSE.txt file.
8 *
9 * THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
10 * DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
11 * IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
12 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
13 */
14
20#ifndef IOTMI_PAL_NETWORK_TRANSPORT_H_
21#define IOTMI_PAL_NETWORK_TRANSPORT_H_
22
23#include <stdbool.h>
24#include <stddef.h>
25#include <stdint.h>
26
27#include "core_pkcs11.h"
28#include "transport_interface.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
37#define IOTMI_PSK_TOKEN_SIZE 32
38
42#define IOTMI_PSK_IDENTITY_SIZE 32
43
57
62typedef struct NetworkContext* NetworkContextHandle_t;
63
79
86typedef void (*iotmiPal_TransportReceiveCallback_t)(void* pCallbackContext);
87
100 NetworkContextHandle_t networkContextHandle, const char* pHostName,
101 uint16_t port,
102 const iotmiPal_TransportPkcs11Credentials_t* pTransportPkcs11Credentials);
103
111
119 void* pBuffer, size_t bytesToRecv);
120
128 const void* pBuffer, size_t bytesToSend);
129
145 NetworkContextHandle_t networkContextHandle,
147 void* pCallbackContext);
148
149#if IOTMI_USE_WSS_PROVISIONEE == 1
150
160int32_t iotmiPal_tcpTransportConnect(
161 NetworkContextHandle_t networkContextHandle, const char* pHostName,
162 uint16_t port);
163
171int32_t iotmiPal_tcpTransportRecv(NetworkContextHandle_t networkContextHandle,
172 void* pBuffer, size_t bytesToRecv);
173
181int32_t iotmiPal_tcpTransportSend(NetworkContextHandle_t networkContextHandle,
182 const void* pBuffer, size_t bytesToSend);
183
193int32_t iotmiPal_establishTLSWithSessionToken(
194 NetworkContextHandle_t networkContextHandle,
195 iotmiPal_SessionToken_t* session_token, CK_SESSION_HANDLE p11Session);
196
204uint32_t iotmiPal_htonl(uint32_t hostlong);
205
213uint32_t iotmiPal_ntohl(uint32_t netlong);
214
222uint16_t iotmiPal_ntohs(uint16_t netshort);
223
224#endif /* IOTMI_USE_WSS_PROVISIONEE == 1 */
225
226#ifdef __cplusplus
227}
228#endif
229
230#endif /* ifndef IOTMI_PAL_NETWORK_TRANSPORT_H_ */
int32_t iotmiPal_transportRegisterReceiveCallback(NetworkContextHandle_t networkContextHandle, iotmiPal_TransportReceiveCallback_t pReceiveCallback, void *pCallbackContext)
Setup a callback function for receive. This function is called after a connection is setup....
void(* iotmiPal_TransportReceiveCallback_t)(void *pCallbackContext)
Callback function to be called when transport data is ready.
Definition iotmi_pal_NetworkTransport.h:86
int32_t iotmiPal_transportRecv(NetworkContextHandle_t networkContextHandle, void *pBuffer, size_t bytesToRecv)
Transport interface receive function implementation.
struct iotmiPal_SessionToken iotmiPal_SessionToken_t
Structure to hold session token information.
int32_t iotmiPal_transportSend(NetworkContextHandle_t networkContextHandle, const void *pBuffer, size_t bytesToSend)
Transport interface send function implementation.
int32_t iotmiPal_transportConnectPKCS11(NetworkContextHandle_t networkContextHandle, const char *pHostName, uint16_t port, const iotmiPal_TransportPkcs11Credentials_t *pTransportPkcs11Credentials)
Setup a mutual authenticated TLS connection.
#define IOTMI_PSK_TOKEN_SIZE
PSK token size in bytes (64 hex chars = 32 bytes)
Definition iotmi_pal_NetworkTransport.h:37
struct NetworkContext * NetworkContextHandle_t
Definition iotmi_pal_NetworkTransport.h:62
struct iotmiPal_TransportPkcs11Credentials iotmiPal_TransportPkcs11Credentials_t
Contains the credentials necessary for TLS connection setup.
#define IOTMI_PSK_IDENTITY_SIZE
PSK identity size (32 hex chars)
Definition iotmi_pal_NetworkTransport.h:42
void iotmiPal_transportDisconnect(NetworkContextHandle_t networkContextHandle)
Disconnect TLS connection.
Structure to hold session token information.
Definition iotmi_pal_NetworkTransport.h:47
uint8_t token[IOTMI_PSK_TOKEN_SIZE]
Authentication token as 32-byte PSK key.
Definition iotmi_pal_NetworkTransport.h:49
size_t tokenIdLength
Length of the token ID.
Definition iotmi_pal_NetworkTransport.h:55
size_t tokenLength
Length of the token (always 32 for PSK)
Definition iotmi_pal_NetworkTransport.h:53
char tokenId[IOTMI_PSK_IDENTITY_SIZE+1U]
Token ID string.
Definition iotmi_pal_NetworkTransport.h:51
Contains the credentials necessary for TLS connection setup.
Definition iotmi_pal_NetworkTransport.h:67
char * pPrivateKeyLabel
String representing the PKCS #11 label for the private key.
Definition iotmi_pal_NetworkTransport.h:76
CK_SESSION_HANDLE p11Session
PKCS #11 session handle.
Definition iotmi_pal_NetworkTransport.h:71
char * pRootCaLabel
String representing the PKCS #11 label for the trusted server root certificate.
Definition iotmi_pal_NetworkTransport.h:72
char ** pAlpnProtos
ALPN protocol to use. If not NULL, alpn protocols are provided in a null terminated array of null ter...
Definition iotmi_pal_NetworkTransport.h:69
char * pClientCertLabel
String representing the PKCS #11 label for the client certificate.
Definition iotmi_pal_NetworkTransport.h:74