1*b1d757bcSAlan Somers /* 2*b1d757bcSAlan Somers * Copyright (c) 1983, 1993 3*b1d757bcSAlan Somers * The Regents of the University of California. All rights reserved. 4*b1d757bcSAlan Somers * 5*b1d757bcSAlan Somers * Redistribution and use in source and binary forms, with or without 6*b1d757bcSAlan Somers * modification, are permitted provided that the following conditions 7*b1d757bcSAlan Somers * are met: 8*b1d757bcSAlan Somers * 1. Redistributions of source code must retain the above copyright 9*b1d757bcSAlan Somers * notice, this list of conditions and the following disclaimer. 10*b1d757bcSAlan Somers * 2. Redistributions in binary form must reproduce the above copyright 11*b1d757bcSAlan Somers * notice, this list of conditions and the following disclaimer in the 12*b1d757bcSAlan Somers * documentation and/or other materials provided with the distribution. 13*b1d757bcSAlan Somers * 3. Neither the name of the University nor the names of its contributors 14*b1d757bcSAlan Somers * may be used to endorse or promote products derived from this software 15*b1d757bcSAlan Somers * without specific prior written permission. 16*b1d757bcSAlan Somers * 17*b1d757bcSAlan Somers * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18*b1d757bcSAlan Somers * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*b1d757bcSAlan Somers * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*b1d757bcSAlan Somers * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21*b1d757bcSAlan Somers * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*b1d757bcSAlan Somers * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*b1d757bcSAlan Somers * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*b1d757bcSAlan Somers * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*b1d757bcSAlan Somers * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*b1d757bcSAlan Somers * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*b1d757bcSAlan Somers * SUCH DAMAGE. 28*b1d757bcSAlan Somers * 29*b1d757bcSAlan Somers * $FreeBSD$ 30*b1d757bcSAlan Somers */ 31*b1d757bcSAlan Somers #include <sys/param.h> 32*b1d757bcSAlan Somers #include <sys/ioctl.h> 33*b1d757bcSAlan Somers 34*b1d757bcSAlan Somers #include <net/if.h> 35*b1d757bcSAlan Somers #include <netinet/ip_carp.h> 36*b1d757bcSAlan Somers 37*b1d757bcSAlan Somers #include <string.h> 38*b1d757bcSAlan Somers #include <strings.h> 39*b1d757bcSAlan Somers 40*b1d757bcSAlan Somers #include "libifconfig.h" 41*b1d757bcSAlan Somers #include "libifconfig_internal.h" 42*b1d757bcSAlan Somers 43*b1d757bcSAlan Somers 44*b1d757bcSAlan Somers int 45*b1d757bcSAlan Somers ifconfig_carp_get_info(ifconfig_handle_t *h, const char *name, 46*b1d757bcSAlan Somers struct carpreq *carpr, int ncarpr) 47*b1d757bcSAlan Somers { 48*b1d757bcSAlan Somers struct ifreq ifr; 49*b1d757bcSAlan Somers 50*b1d757bcSAlan Somers bzero(carpr, sizeof(struct carpreq) * ncarpr); 51*b1d757bcSAlan Somers carpr[0].carpr_count = ncarpr; 52*b1d757bcSAlan Somers strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); 53*b1d757bcSAlan Somers ifr.ifr_data = (caddr_t)carpr; 54*b1d757bcSAlan Somers 55*b1d757bcSAlan Somers if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGVH, &ifr) != 0) { 56*b1d757bcSAlan Somers return (-1); 57*b1d757bcSAlan Somers } 58*b1d757bcSAlan Somers 59*b1d757bcSAlan Somers return (0); 60*b1d757bcSAlan Somers } 61