.\" -*- coding: UTF-8 -*- .\" Copyright (c) 2012 YOSHIFUJI Hideaki .\" and Copyright (c) 2012 Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of .\" this manual under the conditions for verbatim copying, provided that .\" the entire resulting derived work is distributed under the terms of .\" a permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume .\" no responsibility for errors or omissions, or for damages resulting .\" from the use of the information contained herein. The author(s) may .\" not have taken the same level of care in the production of this .\" manual, which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH IF_NAMEINDEX 3 "9 juin 2020" GNU "Manuel du programmeur Linux" .SH NOM if_nameindex, if_freenameindex \- Obtenir le nom et l'indice des interfaces réseau .SH SYNOPSIS .nf \fB#include \fP .PP \fBstruct if_nameindex *if_nameindex(\fP\fIvoid\fP\fB);\fP \fBvoid if_freenameindex(struct if_nameindex *\fP\fIptr\fP\fB);\fP .fi .SH DESCRIPTION La fonction \fBif_nameindex\fP() renvoie un tableau de structures \fIif_nameindex\fP, contenant chacune des informations au sujet d'une des interfaces réseau du système local. La structure \fIif_nameindex\fP contient au moins les champs suivants\ : .PP .in +4n .EX unsigned int if_index; /* Index of interface (1, 2, ...) */ char *if_name; /* Null\-terminated name ("eth0", etc.) */ .EE .in .PP The \fIif_index\fP field contains the interface index. The \fIif_name\fP field points to the null\-terminated interface name. The end of the array is indicated by entry with \fIif_index\fP set to zero and \fIif_name\fP set to NULL. .PP La donnée renvoyée par \fBif_nameindex\fP() est dynamiquement allouée et devrait être libérée avec \fBif_freenameindex\fP() lorsqu'elle n'est plus utilisée. .SH "VALEUR RENVOYÉE" En cas de réussite, \fBif_nameindex\fP() renvoie un pointeur vers le tableau. En cas d'erreur, elle renvoie un pointeur NULL et \fIerrno\fP est rempli avec le code d'erreur. .SH ERREURS \fBif_nameindex\fP() peut échouer et remplir \fIerrno\fP si\ : .TP \fBENOBUFS\fP les ressources disponibles sont insuffisantes. .PP \fBgetifaddrs\fP() peut aussi échouer pour les erreurs précisées pour \fBsocket\fP(2), \fBbind\fP(2), \fBgetsockname\fP(2), \fBrecvmsg\fP(2), \fBsendto\fP(2) ou \fBmalloc\fP(3). .SH VERSIONS \fBgetifaddrs\fP() est apparue dans la glibc\ 2.1. Les versions antérieures à la glibc 2.3.4 ne géraient que les interfaces avec des adresses IPv4. La gestion des interfaces qui n'ont pas d'adresse IPv4 n'est disponible que si le noyau gère netlink. .SH ATTRIBUTS Pour une explication des termes utilisés dans cette section, consulter \fBattributes\fP(7). .TS allbox; lb lb lb l l l. Interface Attribut Valeur T{ \fBif_nameindex\fP(), .br \fBif_freenameindex\fP() T} Sécurité des threads MT\-Safe .TE .sp 1 .SH CONFORMITÉ POSIX.1\-2001, POSIX.1\-2008, RFC\ 3493. .PP Cette fonction est d'abord apparue dans BSDi. .SH EXEMPLES Le programme ci\-dessous montre l'utilisation des fonctions décrites dans cette page. Voici un exemple de sortie que ce programme peut produire\ : .PP .in +4n .EX $ \fB./a.out\fP\fI 1: lo 2: wlan0 3: em1\fP .EE .in .SS "Source du programme" .EX #include #include #include #include int main(int argc, char *argv[]) { struct if_nameindex *if_ni, *i; if_ni = if_nameindex(); if (if_ni == NULL) { perror("if_nameindex"); exit(EXIT_FAILURE); } for (i = if_ni; ! (i\->if_index == 0 && i\->if_name == NULL); i++) printf("%u: %s\en", i\->if_index, i\->if_name); if_freenameindex(if_ni); exit(EXIT_SUCCESS); } .EE .SH "VOIR AUSSI" \fBgetsockopt\fP(2), \fBsetsockopt\fP(2), \fBgetifaddrs\fP(3), \fBif_indextoname\fP(3), \fBif_nametoindex\fP(3), \fBifconfig\fP(8) .SH COLOPHON Cette page fait partie de la publication\ 5.10 du projet \fIman\-pages\fP Linux. Une description du projet et des instructions pour signaler des anomalies et la dernière version de cette page peuvent être trouvées à l'adresse \%https://www.kernel.org/doc/man\-pages/. .SH TRADUCTION La traduction française de cette page de manuel a été créée par Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot , Cédric Boutillier et Frédéric Hantrais . Cette traduction est une documentation libre ; veuillez vous reporter à la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License version 3 .UE concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE. Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à .MT debian-l10n-french@lists.debian.org .ME .