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 Group Management Protocol (IGMP) */ 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 30 /* Bring in externs for caller checking code. */ 31 32 NX_CALLER_CHECKING_EXTERNS 33 34 35 /**************************************************************************/ 36 /* */ 37 /* FUNCTION RELEASE */ 38 /* */ 39 /* _nxe_ipv4_multicast_interface_join PORTABLE C */ 40 /* 6.1 */ 41 /* AUTHOR */ 42 /* */ 43 /* Yuxin Zhou, Microsoft Corporation */ 44 /* */ 45 /* DESCRIPTION */ 46 /* */ 47 /* This function checks for errors in the IPv4 multicast join */ 48 /* function call. */ 49 /* */ 50 /* INPUT */ 51 /* */ 52 /* ip_ptr IP instance pointer */ 53 /* group_address Multicast group to join */ 54 /* interface_index Index to the interface */ 55 /* */ 56 /* OUTPUT */ 57 /* */ 58 /* status Completion status */ 59 /* */ 60 /* CALLS */ 61 /* */ 62 /* _nx_ipv4_multicast_interface_join Actual IPv4 multicast join */ 63 /* function */ 64 /* */ 65 /* CALLED BY */ 66 /* */ 67 /* Application Code */ 68 /* */ 69 /* RELEASE HISTORY */ 70 /* */ 71 /* DATE NAME DESCRIPTION */ 72 /* */ 73 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 74 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 75 /* resulting in version 6.1 */ 76 /* */ 77 /**************************************************************************/ _nxe_ipv4_multicast_interface_join(NX_IP * ip_ptr,ULONG group_address,UINT interface_index)78UINT _nxe_ipv4_multicast_interface_join(NX_IP *ip_ptr, ULONG group_address, UINT interface_index) 79 { 80 81 #ifndef NX_DISABLE_IPV4 82 UINT status; 83 84 85 /* Check for invalid input pointers. */ 86 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID)) 87 { 88 return(NX_PTR_ERROR); 89 } 90 91 /* Check for invalid multicast address. */ 92 if ((group_address & NX_IP_CLASS_D_MASK) != NX_IP_CLASS_D_TYPE) 93 { 94 return(NX_IP_ADDRESS_ERROR); 95 } 96 97 /* Validate the interface. */ 98 if ((interface_index >= NX_MAX_PHYSICAL_INTERFACES) || 99 (ip_ptr -> nx_ip_interface[interface_index].nx_interface_valid == NX_FALSE)) 100 { 101 return(NX_INVALID_INTERFACE); 102 } 103 104 /* Check for appropriate caller. */ 105 NX_THREADS_ONLY_CALLER_CHECKING 106 107 /* Call actual IPv4 multicast interface join function. */ 108 status = _nx_ipv4_multicast_interface_join(ip_ptr, group_address, interface_index); 109 110 /* Return completion status. */ 111 return(status); 112 #else /* NX_DISABLE_IPV4 */ 113 NX_PARAMETER_NOT_USED(ip_ptr); 114 NX_PARAMETER_NOT_USED(group_address); 115 NX_PARAMETER_NOT_USED(interface_index); 116 117 return(NX_NOT_SUPPORTED); 118 #endif /* !NX_DISABLE_IPV4 */ 119 } 120 121