Bonjour

J'ai une fonction c++ sous windows qui me permet de lister les interfaces ip d'une machine

voici le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
____________________________________________________________________________________________________________
// Function: GetIPInterfaceList
//
// Description:
//    This function returns an array of SOCKADDR_IN structures,
//    one for every local IP interface on the machine. 
//_____________________________________________________________________________________________________________
SOCKADDR_IN *GetIPInterfaceList(SOCKET s, int *count)
{
    static SOCKADDR_IN  sa_in[MAX_NUM_CSADDRS];
    INTERFACE_INFO      iflist[MAX_INTERFACE_LIST];
    DWORD dwBytes;
    int  ret, i;
 
    *count = 0;
    ret = WSAIoctl(s, SIO_GET_INTERFACE_LIST, NULL, 0, &iflist,
        sizeof(iflist), &dwBytes, NULL, NULL);
    if (ret == SOCKET_ERROR){
        return NULL;
    }
    // Loop through the interfaces and copy them into the SOCKADDR_IN
    // array. 
    //
    *count = dwBytes / sizeof(INTERFACE_INFO); 
    for(i=0; i < *count ;i++)
    {
        memcpy(&sa_in[i], &iflist[i].iiAddress.AddressIn, sizeof(SOCKADDR_IN));
    }
    return sa_in;
}
J essaye de convertir cette fonction sous linux, mais je bloque completement pourriez vous m'indiquer vers quels fonctions ou apim'orienter( gethostbyname() ?)

Merci d'avance

A+ mani