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

Technical Reference: Base Operating System and Extensions, Volume 1


if_nameindex Subroutine

Purpose

Retrieves index and name information for all interfaces.

Library

Library (libinet.a)

Syntax

#include <net/if.h>
 
struct if_nameindex {
unsigned int if_index; /* 1, 2, ... */
char * if_name; /* null terminated name: "le0", ... */
};
struct if_nameindex *if_nameindex (void); 

Description

The final function of four for interface identification. The if_nameindex subroutine returns an array of if_nameindex structures, one structure per interface.

Note: The memory used for this array of structures along with the interface names pointed to by the if_name members is obtained dynamically. Use if_freenameindex (if_freenameindex Subroutine) to free memory allocated by if_nameindex.

Return Values

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

Related Information

The if_nametoindex (if_nametoindex Subroutine) subroutine, if_indextoname (if_indextoname Subroutine) subroutine, and if_freenameindex (if_freenameindex Subroutine) subroutine.

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


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