HedongGao opened a new pull request, #3284:
URL: https://github.com/apache/nuttx-apps/pull/3284
## Summary
The Nuttx network protocol stack supports the Vlan module, and netlib needs
to support Vlan related apis.
## Impact
Users can add or delete Vlan interfaces through the netlib api interface.
## Testing
`
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <netutils/netlib.h>
#define TEST_IFNAME "eth0" // Change to your actual base interface name
#define TEST_VLANID 100 // VLAN ID to test
#define TEST_VLANIF "eth0.100" // Expected VLAN interface name
int main(void)
{
int ret;
printf("Testing netlib_add_vlan()...\n");
ret = netlib_add_vlan(TEST_IFNAME, TEST_VLANID);
if (ret == 0)
{
printf("netlib_add_vlan: SUCCESS (added VLAN %d to %s)\n",
TEST_VLANID, TEST_IFNAME);
}
else
{
printf("netlib_add_vlan: FAILED (errno=%d: %s)\n", errno,
strerror(errno));
return 1;
}
// Optionally, you can check if the VLAN interface exists here
// For simplicity, we just try to delete it
// printf("Testing netlib_del_vlan()...\n");
// ret = netlib_del_vlan(TEST_VLANIF);
// if (ret == 0)
// {
// printf("netlib_del_vlan: SUCCESS (deleted VLAN interface %s)\n",
TEST_VLANIF);
// }
// else
// {
// printf("netlib_del_vlan: FAILED (errno=%d: %s)\n", errno,
strerror(errno));
// return 1;
// }
printf("VLAN add/delete test completed.\n");
return 0;
}
`
--
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]