/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <netdb.h>
#include <nss_dbdefs.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ifaddrs.h>
#include <libsocket_priv.h>
/*
* Create a linked list of `struct ifaddrs' structures, one for each
* address that is UP. If successful, store the list in *ifap and
* return 0. On errors, return -1 and set `errno'.
*
* The storage returned in *ifap is allocated dynamically and can
* only be properly freed by passing it to `freeifaddrs'.
*/
int
{
int err;
char *cp;
return (-1);
}
if (err == 0) {
*cp = '\0';
}
}
return (err);
}
void
{
}
}
/*
* Returns all addresses configured on the system. If flags contain
* LIFC_ENABLED, only the addresses that are UP are returned.
* Address list that is returned by this function must be freed
* using freeifaddrs().
*/
int
{
int ret;
int s, n, numifs;
int sock4;
int sock6;
int err;
return (-1);
return (-1);
}
/* Get all interfaces from SIOCGLIFCONF */
if (ret != 0)
goto fail;
/*
* Loop through the interfaces obtained from SIOCGLIFCOMF
* and retrieve the addresses, netmask and flags.
*/
/* Prepare for the ioctl call */
continue;
goto fail;
continue;
/*
* Allocate the current list node. Each node contains data
* for one ifaddrs structure.
*/
goto fail;
} else {
/* First node in the linked list */
}
goto fail;
goto fail;
sizeof (struct sockaddr_storage));
/* Get the netmask */
goto fail;
goto fail;
sizeof (struct sockaddr_storage));
/* Get the destination for a pt-pt interface */
goto fail;
sizeof (struct sockaddr_storage));
goto fail;
sizeof (struct sockaddr_storage));
goto fail;
sizeof (struct sockaddr_storage));
goto fail;
sizeof (struct sockaddr_storage));
}
}
return (0);
fail:
freeifaddrs(*ifap);
goto retry;
return (-1);
}
/*
* Do a SIOCGLIFCONF and store all the interfaces in `buf'.
*/
int
{
char *tmp;
goto fail;
/*
* When calculating the buffer size needed, add a small number
* of interfaces to those we counted. We do this to capture
* the interface status of potential interfaces which may have
* been plumbed between the SIOCGLIFNUM and the SIOCGLIFCONF.
*/
goto fail;
goto fail;
/*
* If every entry was filled, there are probably
* more interfaces than (lifn.lifn_count + 4).
* Redo the ioctls SIOCGLIFNUM and SIOCGLIFCONF to
* get all the interfaces.
*/
goto retry;
}
return (0);
fail:
return (-1);
}