zs39 opened a new pull request, #17679:
URL: https://github.com/apache/nuttx/pull/17679

   ## Summary
   
   This interface needs to be called in the libc library, but the interface is 
implemented in the kernel, so this interface needs to be exposed
   
   ## Impact
   
   The function's internal implementation was not modified, so it does not 
affect the call.
   
   ## Testing
   
   The following code executes correctly during testing.
   
   ```
   /****************************************************************************
    * apps/examples/hello/hello_main.c
    *
    * SPDX-License-Identifier: Apache-2.0
    *
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.  The
    * ASF licenses this file to you under the Apache License, Version 2.0 (the
    * "License"); you may not use this file except in compliance with the
    * License.  You may obtain a copy of the License at
    *
    *   http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
    * License for the specific language governing permissions and limitations
    * under the License.
    *
    
****************************************************************************/
   
   /****************************************************************************
    * Included Files
    
****************************************************************************/
   
   #include <nuttx/config.h>
   #include <stdio.h>
   
   #ifdef CONFIG_NET_IPv6
   #include <nuttx/net/ip.h>
   #endif
   
   /****************************************************************************
    * Public Functions
    
****************************************************************************/
   
   /****************************************************************************
    * hello_main
    
****************************************************************************/
   
   int main(int argc, FAR char *argv[])
   {
   #ifdef CONFIG_NET_IPv6
     /* Test case 1: Same subnet (should return true) */
     net_ipv6addr_t addr1 = {0x2001, 0x0db8, 0x85a3, 0x0000, 0x0000, 0x8a2e, 
0x0370, 0x7334};
     net_ipv6addr_t addr2 = {0x2001, 0x0db8, 0x85a3, 0x0000, 0x0000, 0x8a2e, 
0x0370, 0x7335};
     net_ipv6addr_t mask = {0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 
0x0000, 0x0000};
     bool result1 = net_ipv6addr_maskcmp(addr1, addr2, mask);
     printf("Test 1 - Same subnet: %s\n", result1 ? "PASS" : "FAIL");
   
     /* Test case 2: Different subnet (should return false) */
     net_ipv6addr_t addr3 = {0x2001, 0x0db8, 0x85a3, 0x0000, 0x0000, 0x8a2e, 
0x0370, 0x7334};
     net_ipv6addr_t addr4 = {0x2001, 0x0db8, 0x85a4, 0x0000, 0x0000, 0x8a2e, 
0x0370, 0x7334};
     bool result2 = net_ipv6addr_maskcmp(addr3, addr4, mask);
     printf("Test 2 - Different subnet: %s\n", !result2 ? "PASS" : "FAIL");
   
     /* Test case 3: Same address (should return true) */
     net_ipv6addr_t addr5 = {0x2001, 0x0db8, 0x85a3, 0x0000, 0x0000, 0x8a2e, 
0x0370, 0x7334};
     net_ipv6addr_t addr6 = {0x2001, 0x0db8, 0x85a3, 0x0000, 0x0000, 0x8a2e, 
0x0370, 0x7334};
     net_ipv6addr_t mask_full = {0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 
0xffff, 0xffff, 0xffff};
     bool result3 = net_ipv6addr_maskcmp(addr5, addr6, mask_full);
     printf("Test 3 - Same address: %s\n", result3 ? "PASS" : "FAIL");
   
     printf("All tests completed!\n");
   #else
     printf("Hello, World!!\n");
     printf("IPv6 support is not enabled (CONFIG_NET_IPv6)\n");
   #endif
   
     return 0;
   }
   ```
   The execution results are as follows
   ```
   nsh> hello
   Test 1 - Same subnet: PASS
   Test 2 - Different subnet: PASS
   Test 3 - Same address: PASS
   All tests completed!
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to