1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Component                                                        */
16 /**                                                                       */
17 /**   Internet Protocol (IP)                                              */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define NX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "nx_api.h"
28 #include "nx_ip.h"
29 #ifdef NX_ENABLE_DUAL_PACKET_POOL
30 #include "nx_packet.h"
31 
32 /* Bring in externs for caller checking code.  */
33 
34 NX_CALLER_CHECKING_EXTERNS
35 #endif /* NX_ENABLE_DUAL_PACKET_POOL */
36 
37 
38 /**************************************************************************/
39 /*                                                                        */
40 /*  FUNCTION                                               RELEASE        */
41 /*                                                                        */
42 /*    _nxe_ip_auxiliary_packet_pool_set                   PORTABLE C      */
43 /*                                                           6.1          */
44 /*  AUTHOR                                                                */
45 /*                                                                        */
46 /*    Yuxin Zhou, Microsoft Corporation                                   */
47 /*                                                                        */
48 /*  DESCRIPTION                                                           */
49 /*                                                                        */
50 /*    This function checks for errors in the auxiliary packet pool set    */
51 /*    function call.                                                      */
52 /*                                                                        */
53 /*  INPUT                                                                 */
54 /*                                                                        */
55 /*    ip_ptr                                Pointer to IP control block   */
56 /*    auxiliary_pool                        Pointer to a valid auxiliary  */
57 /*                                            pool to be used as an       */
58 /*                                            auxiliary packet pool       */
59 /*                                                                        */
60 /*  OUTPUT                                                                */
61 /*                                                                        */
62 /*    status                                Completion status             */
63 /*                                                                        */
64 /*  CALLS                                                                 */
65 /*                                                                        */
66 /*    _nx_ip_auxiliary_packet_pool_set      Actual auxiliary packet pool  */
67 /*                                           set function                 */
68 /*                                                                        */
69 /*  CALLED BY                                                             */
70 /*                                                                        */
71 /*    Application Code                                                    */
72 /*                                                                        */
73 /*  RELEASE HISTORY                                                       */
74 /*                                                                        */
75 /*    DATE              NAME                      DESCRIPTION             */
76 /*                                                                        */
77 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
78 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
79 /*                                            resulting in version 6.1    */
80 /*                                                                        */
81 /**************************************************************************/
_nxe_ip_auxiliary_packet_pool_set(NX_IP * ip_ptr,NX_PACKET_POOL * auxiliary_pool)82 UINT  _nxe_ip_auxiliary_packet_pool_set(NX_IP *ip_ptr, NX_PACKET_POOL *auxiliary_pool)
83 {
84 #ifdef NX_ENABLE_DUAL_PACKET_POOL
85 UINT status;
86 
87 
88     /* Check for invalid input pointers.  */
89     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
90     {
91         return(NX_PTR_ERROR);
92     }
93 
94     /* Check for invalid input pointers.  */
95     if ((auxiliary_pool == NX_NULL) || (auxiliary_pool -> nx_packet_pool_id != NX_PACKET_POOL_ID))
96     {
97         return(NX_PTR_ERROR);
98     }
99 
100     /* Check for appropriate caller.  */
101     NX_INIT_AND_THREADS_CALLER_CHECKING
102 
103     /* Call actual auxiliary packet pool set function.  */
104     status =  _nx_ip_auxiliary_packet_pool_set(ip_ptr, auxiliary_pool);
105 
106     /* Return completion status.  */
107     return(status);
108 
109 #else /* !NX_ENABLE_DUAL_PACKET_POOL */
110     NX_PARAMETER_NOT_USED(ip_ptr);
111     NX_PARAMETER_NOT_USED(auxiliary_pool);
112 
113     return(NX_NOT_SUPPORTED);
114 
115 #endif /* NX_ENABLE_DUAL_PACKET_POOL */
116 }
117 
118