{"id":5716,"date":"2022-12-20T18:57:29","date_gmt":"2022-12-20T21:57:29","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/ipcalc-c-fr\/"},"modified":"2022-12-20T18:57:29","modified_gmt":"2022-12-20T21:57:29","slug":"ipcalc-c-fr","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/ipcalc-c-fr\/","title":{"rendered":"ipcalc.c (fr)"},"content":{"rendered":"<h1 align=\"center\">ipcalc.c<\/h1>\n<p> <a href=\"#NOM\">NOM<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION D\u00c3TAILL\u00c3E\">DESCRIPTION D\u00c3TAILL\u00c3E<\/a><br \/> <a href=\"#DOCUMENTATION DES FONCTIONS\">DOCUMENTATION DES FONCTIONS<\/a><br \/> <a href=\"#AUTEUR\">AUTEUR<\/a> <\/p>\n<hr>\n<h2>NOM <a name=\"NOM\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">ipcalc.c \u2212 fournit des utilitaires pour manipuler des adresses IP.<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><tt>#include <ctype.h> <br \/> #include <popt.h> #include <stdio.h> <br \/> #include <stdlib.h> <br \/> #include <string.h> <br \/> #include <sys\/socket.h> <br \/> #include <netinet\/in.h> <br \/> #include <arpa\/inet.h> <br \/> #include <netdb.h><\/tt><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>D\u00c3\u00a9finitions<\/b><\/p>\n<p style=\"margin-left:17%;\">#define <b>IPBITS<\/b> (sizeof(unsigned long int) bodies manpages.csv script_extrae_body.sh script.sh usr 8) <i><br \/> le nombre de bits dans un adresse IP.<\/i> <br \/> #define <b>IPBYTES<\/b> (sizeof(unsigned long int)) <i><br \/> le nombre d\u2019octets dans une adresse IP.<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Fonctions<\/b><\/p>\n<p style=\"margin-left:17%;\">unsigned long int <b>prefix2mask<\/b> (int prefix) <i><br \/> cr\u00c3\u00a9e un masque r\u00c3\u00a9seau d\u2019un nombre de bits sp\u00c3\u00a9cifi\u00c3\u00a9.<\/i> <br \/> int <b>mask2prefix<\/b> (unsigned long int mask) <i><br \/> calcule le nombre de bits masqu\u00c3\u00a9s par un masque r\u00c3\u00a9seau.<\/i> <br \/> unsigned long int <b>default_netmask<\/b> (unsigned long int addr) <i><br \/> renvoie le masque r\u00c3\u00a9seau par d\u00c3\u00a9faut (canonique) associ\u00c3\u00a9 \u00c3\u00a0 l\u2019adresse IP sp\u00c3\u00a9cifi\u00c3\u00a9e.<\/i> <br \/> unsigned long int <b>calc_broadcast<\/b> (unsigned long int addr, int prefix) <i><br \/> calcule l\u2019adresse de diffusion \u00c3\u00a0 partir d\u2019une adresse IP et d\u2019une longueur de pr\u00c3\u00a9fixe.<\/i> <br \/> unsigned long int <b>calc_network<\/b> (unsigned long int addr, int prefix) <i><br \/> calcule l\u2019adresse r\u00c3\u00a9seau pour une adresse IP et un pr\u00c3\u00a9fixe donn\u00c3\u00a9s.<\/i> <br \/> const char* <b>get_hostname<\/b> (unsigned long int addr) <i><br \/> retourne le nom d\u2019h\u00c3\u00b4te associ\u00c3\u00a9 \u00c3\u00a0 l\u2019adresse IP indiqu\u00c3\u00a9e.<\/i> <br \/> int <b>main<\/b> (int argc, const char **argv) <i><br \/> programme d\u2019appel (NdT : wrapper&#8221;)<\/i>pour<i>les<\/i>fonctions<i>ipcalc.<\/i>&#8220;<\/p>\n<h2>DESCRIPTION D\u00c3TAILL\u00c3E <a name=\"DESCRIPTION D\u00c3TAILL\u00c3E\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">fournit des utilitaires pour manipuler des adresses IP.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">ipcalc fournit des utilitaires et une interface en ligne de commande pour la manipulation d\u2019adresses IP, et le calcul de divers aspects li\u00c3\u00a9s \u00c3\u00a0 IP, addresse\/masque-r\u00c3\u00a9seau\/adresse-r\u00c3\u00a9seau\/pr\u00c3\u00a9fixe\/etc.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Les fonctions peuvent \u00c3\u00aatre acc\u00c3\u00a9d\u00c3\u00a9es \u00c3\u00a0 partir de l\u2019interface de la biblioth\u00c3\u00a8que dans d\u2019autres langages, comme document\u00c3\u00a9 ici. Pour utiliser ipcalc \u00c3\u00a0 partir du shell, lisez la page de manuel ipcalc(1).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Lorsque vous passez des param\u00c3\u00a8tres aux diverses fonctions, veuillez noter si elles prennent l\u2019ordre d\u2019octet h\u00c3\u00b4te (NdT : &#8220;host byte order&#8221;) ou l\u2019ordre d\u2019octet r\u00c3\u00a9seau (NdT : &#8220;network byte order&#8221;). La plupart prennent l\u2019ordre d\u2019octet h\u00c3\u00b4te, et renvoient l\u2019ordre d\u2019octet h\u00c3\u00b4te, mais il y a des exceptions.<\/p>\n<h2>DOCUMENTATION DES FONCTIONS <a name=\"DOCUMENTATION DES FONCTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>unsigned long int calc_broadcast (unsigned long int addr, int prefix)<\/b> <br \/> calcule l\u2019adresse de diffusion \u00c3\u00a0 partir d\u2019une adresse IP et d\u2019une longueur de pr\u00c3\u00a9fixe donn\u00c3\u00a9s.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Param\u00c3\u00a8tres:<\/b><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><i>addr<\/i><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"67%\">\n<p>une adresse IP dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau.<\/p>\n<\/td>\n<td width=\"11%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><i>prefix<\/i><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"67%\">\n<p>une longueur de pr\u00c3\u00a9fixe.<\/p>\n<\/td>\n<td width=\"11%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Renvoie:<\/b><\/p>\n<p style=\"margin-left:17%;\">l\u2019adresse de diffusion calcul\u00c3\u00a9e pour le r\u00c3\u00a9seau, dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>unsigned long int calc_network (unsigned long int addr, int prefix)<\/b> <br \/> calcule l\u2019adresse r\u00c3\u00a9seau pour une adresse et un pr\u00c3\u00a9fixe sp\u00c3\u00a9cifi\u00c3\u00a9s.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Param\u00c3\u00a8tres :<\/b><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><i>addr<\/i><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"67%\">\n<p style=\"margin-top: 1em\">une adresse IP, dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau<\/p>\n<\/td>\n<td width=\"11%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><i>prefix<\/i><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"67%\">\n<p>le pr\u00c3\u00a9fixe r\u00c3\u00a9seau<\/p>\n<\/td>\n<td width=\"11%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Renvoie :<\/b><\/p>\n<p style=\"margin-left:17%;\">l\u2019adresse de base du r\u00c3\u00a9seau avec lequel addr est associ\u00c3\u00a9, dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>unsigned long int default_netmask (unsigned long int addr)<\/b> <br \/> renvoie le masque r\u00c3\u00a9seau par d\u00c3\u00a9faut (canonique) associ\u00c3\u00a9 avec l\u2019adresse IP sp\u00c3\u00a9cifi\u00c3\u00a9e.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Quand Internet a \u00c3\u00a9t\u00c3\u00a9 cr\u00c3\u00a9\u00c3\u00a9, les adresses IP furent segment\u00c3\u00a9es en trois classes de r\u00c3\u00a9seau : A, B, et C. Cette fonction renvoie un masque r\u00c3\u00a9seau qui est associ\u00c3\u00a9 avec l\u2019adresse IP sp\u00c3\u00a9cifi\u00c3\u00a9e, ce qui d\u00c3\u00a9finit dans quelle classe elle se trouve.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Param\u00c3\u00a8tres :<\/b><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"6%\">\n<p style=\"margin-top: 1em\"><i>addr<\/i><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"67%\">\n<p style=\"margin-top: 1em\">une adresse IP dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau.<\/p>\n<\/td>\n<td width=\"11%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Renvoie :<\/b><\/p>\n<p style=\"margin-left:17%;\">un masque r\u00c3\u00a9seau dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>const char bodies manpages.csv script_extrae_body.sh script.sh usr get_hostname (unsigned long int addr)<\/b> <br \/> renvoie le nom d\u2019h\u00c3\u00b4te associ\u00c3\u00a9 avec l\u2019adresse IP sp\u00c3\u00a9cifi\u00c3\u00a9e.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Param\u00c3\u00a8tres :<\/b><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"6%\">\n<p style=\"margin-top: 1em\"><i>addr<\/i><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">une adresse IP pour laquelle on veut un nom d\u2019h\u00c3\u00b4te, dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Renvoie :<\/b><\/p>\n<p style=\"margin-left:17%;\">un nom d\u2019h\u00c3\u00b4te, ou NULL s\u2019il ne peut \u00c3\u00aatre d\u00c3\u00a9termin\u00c3\u00a9. Le nom d\u2019h\u00c3\u00b4te est stock\u00c3\u00a9 dans un buffer statique qui pourra dispara\u00c3\u00aetre \u00c3\u00a0 n\u2019importe quel moment, l\u2019appelant devra copier la donn\u00c3\u00a9e si elle doit \u00c3\u00aatre conserv\u00c3\u00a9e de mani\u00c3\u00a8re permanente.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>main (int argc, const char bodies manpages.csv script_extrae_body.sh script.sh usr argv)<\/b> <br \/> programme d\u2019appel (&#8220;wrapper&#8221;) pour les fonctions ipcalc.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">C\u2019est un programme d\u2019appel (&#8220;wrapper&#8221;) pour les fonctions que la biblioth\u00c3\u00a8que ipcalc fournit. Il peut \u00c3\u00aatre utilis\u00c3\u00a9 \u00c3\u00a0 partir de shells scripts ou directement \u00c3\u00a0 partir de la ligne de commande.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Pour plus d\u2019information, veuillez vous r\u00c3\u00a9f\u00c3\u00a9rer \u00c3\u00a0 la page de manuel ipcalc(1).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>int mask2prefix (unsigned long int mask)<\/b> <br \/> calcule le nombre de bits masqu\u00c3\u00a9s par un masque r\u00c3\u00a9seau.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Cette fonction calcule les bits significatifs d\u2019une adresse IP en fonction d\u2019un masque r\u00c3\u00a9seau. Voir aussi <b>prefix2mask<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Param\u00c3\u00a8tres:<\/b><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"6%\">\n<p style=\"margin-top: 1em\"><i>mask<\/i><\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">est le masque r\u00c3\u00a9seau, specifi\u00c3\u00a9 comme un entier long non sign\u00c3\u00a9 dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Renvoie :<\/b><\/p>\n<p style=\"margin-left:17%;\">le nombre de bits significatifs.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>unsigned long int prefix2mask (int bits)<\/b> <br \/> cr\u00c3\u00a9e un masque r\u00c3\u00a9seau \u00c3\u00a0 partir d\u2019un nombre de bits sp\u00c3\u00a9cifi\u00c3\u00a9.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Cette fonction convertir une longueur de pr\u00c3\u00a9fixe en masque r\u00c3\u00a9seau. Comme le CIDR (classless internet domain internet domain routing) has taken off, de plus en plus d\u2019adresses IP donn\u00c3\u00a9es dans le format addresse\/pr\u00c3\u00a9fixe (i.e. 192.168.2.3\/24, avec masque r\u00c3\u00a9seau correspondant 255.255.255.0). Si vous voulez voir quel masque r\u00c3\u00a9seau correspond \u00c3\u00a0 la partie pr\u00c3\u00a9fixe, c\u2019est cette fonction qu\u2019il vous faut. Voir aussi <b>mask2prefix<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Param\u00c3\u00a8tres :<\/b><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><i>prefix<\/i><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">est le nombre de bits pour lesquels il faut cr\u00c3\u00a9er un masque r\u00c3\u00a9seau.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Renvoie :<\/b><\/p>\n<p style=\"margin-left:17%;\">un masque r\u00c3\u00a9seau, dans l\u2019ordre d\u2019octet r\u00c3\u00a9seau.<\/p>\n<h2>AUTEUR <a name=\"AUTEUR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">G\u00c3\u00a9n\u00c3\u00a9r\u00c3\u00a9 automatiquement par Doxygen pour initscripts \u00c3\u00a0 partir du code source (NdT : je comprends mieux :)).<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>ipcalc.c NOM SYNOPSIS DESCRIPTION D\u00c3TAILL\u00c3E DOCUMENTATION DES FONCTIONS AUTEUR NOM ipcalc.c \u2212 fournit des utilitaires pour manipuler des adresses IP. SYNOPSIS #include #include #include #include #include #include #include #include #include D\u00c3\u00a9finitions #define IPBITS (sizeof(unsigned long int) bodies manpages.csv script_extrae_body.sh script.sh usr 8) le nombre de bits dans un adresse IP. #define IPBYTES (sizeof(unsigned long int)) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,2502,2537],"class_list":["post-5716","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-fr","tag-ipcalc_c"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=5716"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5716\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=5716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=5716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=5716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}