Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(void) {
- struct nl_sock *sock;
- struct nl_cache *cache;
- if (!(sock = nl_socket_alloc())) {
- perror("nl_socket_alloc");
- return -1;
- }
- if (nl_connect(sock, NETLINK_ROUTE) < 0) {
- perror("nl_connect");
- nl_socket_free( sock );
- return -1;
- }
- if (rtnl_link_alloc_cache(sock, AF_UNSPEC, &cache) < 0) {
- perror("rtnl_link_alloc_cache");
- nl_socket_free( sock );
- nl_close( sock );
- return -1;
- }
- {
- int ifindex, rc, flags;
- struct rtnl_link *link = NULL;
- if (!(ifindex = rtnl_link_name2i(cache, "eno1.10"))) {
- perror("rtnl_link_name2i");
- return -1;
- }
- printf("ind: %dn", ifindex);
- if (!(link = rtnl_link_get(cache, ifindex))) {
- perror("rtnl_link_get");
- return -1;
- }
- if (rtnl_link_is_vlan(link)) {
- puts("It's VLAN link");
- /* alas it's not about the 'real' device */
- printf("master: %dn", rtnl_link_get_master(link));
- } else
- puts("It's 'real' link");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement