Salve a tutti. Sto usando questa porzione di codice
scritta in freepascal per ottenere l'elenco delle interfacce di rete di cui un computer dispone.Codice PHP:sock:= socket(AF_INET, SOCK_DGRAM, 0);
if sock>= 0 then begin
ifc.ifc_len:= SizeOf(ifr);
ifc.ifc_ifcu.ifcu_req:= ifr;
if ioctl(sock, SIOCGIFCONF, @ifc)>= 0 then begin
for I:= 0 to ifc.ifc_len div SizeOf(ifreq)- 1 do begin
RigaOut:= ifr[I].ifr_ifrn.ifrn_name+ ', '+ GetMacAddress(ifr[I].ifr_ifrn.ifrn_name);
if (GetFlags(ifr[I].ifr_ifrn.ifrn_name) and IFF_LOOPBACK)<> 0 then RigaOut:= RigaOut+ ', Loopbak';
if ioctl(sock, SIOCGIWNAME, @ifr[I])= 0 then RigaOut:= RigaOut+ ', Wireless.';
if (GetFlags(ifr[I].ifr_ifrn.ifrn_name) and IFF_UP)<> 0 then RigaOut:= RigaOut+ ', Up.' else RigaOut:= RigaOut+ ', Down.';
InterfacesList:= InterfacesList+ Chr(13)+ Chr(10)+ RigaOut;
end;
end;
libc.__close(sock);
end;
Funziona ma mi ritorna soltanto l'elenco delle interfacce configurate. Come posso invece ottenere l'elenco di tutte le interfacce? Non riesco a trovare documentazione!
Vanno bene esempi in C, C++ e fpc.
Grazie mille, Denis.

Rispondi quotando