1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Secure Component                                                 */
17 /**                                                                       */
18 /**    Transport Layer Security (TLS)                                     */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SECURE_SOURCE_CODE
24 
25 
26 #include "nx_secure_tls.h"
27 
28 /* Bring in externs for caller checking code.  */
29 
30 NX_SECURE_CALLER_CHECKING_EXTERNS
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nxe_secure_tls_session_packet_pool_set             PORTABLE C      */
37 /*                                                           6.2.0        */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yanwu Cai, Microsoft Corporation                                    */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function checks for errors when setting the packet pool.       */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    tls_session                           TLS control block             */
49 /*    packet_pool                           Pointer to the packet pool    */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _nx_secure_tls_session_packet_pool_set                              */
58 /*                                          Actual packet pool set        */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    Application Code                                                    */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  10-31-2022     Yanwu Cai                Initial Version 6.2.0         */
69 /*                                                                        */
70 /**************************************************************************/
_nxe_secure_tls_session_packet_pool_set(NX_SECURE_TLS_SESSION * tls_session,NX_PACKET_POOL * packet_pool)71 UINT _nxe_secure_tls_session_packet_pool_set(NX_SECURE_TLS_SESSION *tls_session,
72                                              NX_PACKET_POOL *packet_pool)
73 {
74 UINT status;
75 
76 
77     if (tls_session == NX_NULL)
78     {
79         return(NX_PTR_ERROR);
80     }
81 
82     /* Make sure the session is initialized. */
83     if(tls_session -> nx_secure_tls_id != NX_SECURE_TLS_ID)
84     {
85         return(NX_SECURE_TLS_SESSION_UNINITIALIZED);
86     }
87 
88     /* Check for appropriate caller.  */
89     NX_THREADS_ONLY_CALLER_CHECKING
90 
91     /* We want to be able to set the packet pool to NX_NULL to use the default packet pool, so don't check for it. */
92     status = _nx_secure_tls_session_packet_pool_set(tls_session, packet_pool);
93 
94     return(status);
95 }
96 
97