Skip to content

Conversation

@HedongGao
Copy link
Contributor

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;

}
`

Add support for adding/removing VLAN device

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants