#include "stock.h" int my_hardware(char *hdw) int my_hostname(char *name) int my_ip(char *hostname, char *ipc, int *ip) int my_os(char *name) int my_username(char *name) int my_ipv6s(struct sockaddr_storage *sa, int max_sa_cnt)
my_ipv6s returns a list of the addresses of the current machine, both ipv6 and ipv4; it returns a count.
my_hardware returns "i686" my_hostname returns "ouray" my_ip returns "ouray.brtt.com", "206.168.219.188", and the integer 0xbcdba8ce my_os returns "Linux" my_username returns "danq" # Here's a fragmentary example of ipv6s struct sockaddr_storage sa[MAXSA] ; n = my_ipv6s(sa, MAXSA) ; for (int i=0 ; i<n ; i++ ) { char ip[64] ; bt_inet_ntop((struct sockaddr *) (sa+i), ip, sizeof(ip)) ; switch ( (sa+i)->ss_family ) { case AF_INET: err = getnameinfo((struct sockaddr *) (sa+i), sizeof(struct sockaddr_in), hostname, sizeof(hostname), servname, sizeof(servname), flags ) ; break; case AF_INET6: err = getnameinfo((struct sockaddr *) (sa+i), sizeof(struct sockaddr_in6), hostname, sizeof(hostname), 0, 0, flags ) ; break; } printf("hostname='%s' servname='%s'\n", okstr(hostname), okstr(servname) ) ; if ( err != 0 ) { fprintf(stderr, "getnameinfo failed: %s\n", strerror(errno)) ; } printf("%i %s\n", i, ip ) ; }
my_ipv6s returns a count of the number of ip addresses returned.
uname(2) ifconfig(8)
Instead of my_ip, use my_ips and/or my_ipv6s.