summaryrefslogtreecommitdiff
path: root/common/src/nx_ip_deferred_link_status_process.c
blob: ad5956d0c8d02bc748054f8c52766f3121ffccb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/***************************************************************************
 * Copyright (c) 2024 Microsoft Corporation
 * Copyright (c) 2025-present Eclipse ThreadX Contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * SPDX-License-Identifier: MIT
 **************************************************************************/


/**************************************************************************/
/**************************************************************************/
/**                                                                       */
/** NetX Component                                                        */
/**                                                                       */
/**   Internet Protocol (IP)                                              */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/

#define NX_SOURCE_CODE

/* Include necessary system files. */
#include "nx_api.h"
#include "nx_tcp.h"
#include "nx_arp.h"
#include "nx_icmpv6.h"
#include "nx_link.h"


/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _nx_ip_diferred_link_status_process                 PORTABLE C      */
/*                                                           6.4.3        */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Yuxin Zhou, Microsoft Corporation                                   */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This function processes link status change event.                   */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    ip_ptr                                Pointer to IP control block   */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    None                                                                */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    tx_mutex_get                          Obtain protection mutex       */
/*    tx_mutex_put                          Release protection mutex      */
/*    _nx_tcp_socket_connection_reset       Reset TCP connection          */
/*    _nx_arp_interface_entries_delete      Remove specified ARP entries  */
/*    _nx_nd_cache_interface_entries_delete Delete ND cache entries assoc-*/
/*                                          iated with specified interface*/
/*    link_driver_entry                     Link driver                   */
/*    memset                                Zero out the interface        */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*    nx_ip_thread_entry                                                  */
/*                                                                        */
/**************************************************************************/
VOID _nx_ip_deferred_link_status_process(NX_IP *ip_ptr)
{

UINT         i;
NX_IP_DRIVER driver_request;
ULONG        link_up;

    if (ip_ptr -> nx_ip_link_status_change_callback == NX_NULL)
    {

        /* Callback function is not set. */
        return;
    }

    for (i = 0; i < NX_MAX_PHYSICAL_INTERFACES; i++)
    {
        if ((ip_ptr -> nx_ip_interface[i].nx_interface_valid) &&
            (ip_ptr -> nx_ip_interface[i].nx_interface_link_status_change))
        {

            /* Reset the flag. */
            ip_ptr -> nx_ip_interface[i].nx_interface_link_status_change = NX_FALSE;

            driver_request.nx_ip_driver_ptr       = ip_ptr;
            driver_request.nx_ip_driver_command   = NX_LINK_GET_STATUS;
            driver_request.nx_ip_driver_interface = &(ip_ptr -> nx_ip_interface[i]);
            driver_request.nx_ip_driver_return_ptr = &link_up;

            (ip_ptr -> nx_ip_interface[i].nx_interface_link_driver_entry)(&driver_request);

            /* Invoke the callback function. */
            /*lint -e{644} suppress variable might not be initialized, since "link_up" was initialized in nx_interface_link_driver_entry. */
            ip_ptr -> nx_ip_link_status_change_callback(ip_ptr, i, link_up);

#ifdef NX_ENABLE_VLAN
            /* Link status change need to propagate to vlan sub interface */
            nx_link_vlan_interface_status_change(ip_ptr, i);
#endif /* NX_ENABLE_VLAN */
        }
    }
}