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_ipv6.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _nxd_ipv6_address_change_notify                     PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Yuxin Zhou, Microsoft Corporation                                   */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function registers an application callback routine that NetX   */
44 /*    Duo calls whenever the IPv6 Address is changed.                     */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    ip_ptr                                IP control block pointer      */
49 /*    ip_address_change_notify              Application callback function */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    tx_mutex_get                          Get protection mutex          */
58 /*    tx_mutex_put                          Put protection mutex          */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    Application Code                                                    */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
69 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*                                                                        */
72 /**************************************************************************/
_nxd_ipv6_address_change_notify(NX_IP * ip_ptr,VOID (* ip_address_change_notify)(NX_IP * ip_ptr,UINT status,UINT interface_index,UINT address_index,ULONG * ip_address))73 UINT  _nxd_ipv6_address_change_notify(NX_IP *ip_ptr, VOID (*ip_address_change_notify)(NX_IP *ip_ptr, UINT status, UINT interface_index, UINT address_index, ULONG *ip_address))
74 {
75 
76 #if defined(NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY) && defined(FEATURE_NX_IPV6)
77 TX_INTERRUPT_SAVE_AREA
78 
79 
80     /* If trace is enabled, insert this event into the trace buffer.  */
81     NX_TRACE_IN_LINE_INSERT(NXD_TRACE_IPV6_ADDRESS_CHANGE_NOTIFY, ip_ptr, ip_address_change_notify, 0, 0, NX_TRACE_IP_EVENTS, 0, 0);
82 
83     /* Get mutex protection.  */
84     tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
85 
86     /* Disable interrupts.  */
87     TX_DISABLE
88 
89     /* Setup the IP address change callback function and the additional information pointers. */
90     ip_ptr -> nx_ipv6_address_change_notify =  ip_address_change_notify;
91 
92     /* Restore interrupts.  */
93     TX_RESTORE
94 
95     /* Release mutex protection.  */
96     tx_mutex_put(&(ip_ptr -> nx_ip_protection));
97 
98     /* Return completion status.  */
99     return(NX_SUCCESS);
100 
101 #else
102     NX_PARAMETER_NOT_USED(ip_ptr);
103     NX_PARAMETER_NOT_USED(ip_address_change_notify);
104 
105     return(NX_NOT_SUPPORTED);
106 
107 #endif /* NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY && FEATURE_NX_IPV6 */
108 }
109 
110