[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

if_nameindex Subroutine

Purpose

Retrieves index and name information for all interfaces.

Library

The Standard C Library (<libc.a>)

Syntax

#include <net/if.h>

struct if_nameindex *if_nameindex(void)
struct if_nameindex {
unsigned int if_index; /* 1, 2, ... */
char *if_name; /* null terminated name: "le0", ... */
};

Description

The if_nameindex subroutine returns an array of if_nameindex structures (one per interface).

The memory used for this array of structures is obtained dynamically. The interface names pointed to by the if_name members are obtained dynamically as well. This memory is freed by the if_freenameindex subroutine.

The function returns a NULL pointer upon error, and sets the errno global value to the appropriate value. If successful, the function returns an array of structures. The end of an array of structures is indicated by a structure with an if_index value of 0 and an if_name value of NULL.

Related Information

if_nametoindex Subroutine, if_indextoname Subroutine, and if_freenameindex Subroutine.

Subroutines Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]