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