pump.h

00001 /* pump.h
00002  *
00003  * libdhcp pump compatibility API for anaconda -
00004  * only the pump symbols used by anaconda are defined.
00005  *
00006  ******************************************************************************
00007  * Original pump credits:
00008  * 
00009  * There are a bunch of folks who made this code possible. I'm sure I've missed
00010  * some in this list :-(
00011  *
00012  *  Alan Cox <alan@redhat.com>
00013  *  Bruce Beare <bbeare@cisco.com>
00014  *  David Blythe <blythe@routefree.com>
00015  *  Stephen Carville <carville@cpl.net>
00016  *  Guy Delamarter <delamart@pas.rochester.edu>
00017  *  Chris Johnson <cjohnson@mint.net>
00018  *  Michael Johnson <johnsonm@redhat.com>
00019  *  H. J. Lu <hjl@valinux.com>
00020  *  Kristof Petr <Petr@Kristof.CZ>
00021  *  Marco Pietrobono <pietrobo@pietrobo.com>
00022  *  Benjamin Reed <breed@cse.ucsc.edu>
00023  *  George Staikos <staikos@0wned.org>
00024  *  Jay Turner <jturner@redhat.com>
00025  *  Matt Wilson <msw@redhat.com>
00026  *  <aaron@schrab.com>
00027  *  <duanev@io.com>
00028  *  <dunham@cse.msu.edu>
00029  *  <safford@watson.ibm.com>
00030  *  weejock@ferret.lmh.ox.ac.uk
00031  *
00032  *******************************************************************************
00033  *
00034  * Copyright 1999-2001 Red Hat, Inc.
00035  * 
00036  * All Rights Reserved.
00037  * 
00038  * The above copyright notice and this permission notice shall be included in
00039  * all copies or substantial portions of the Software.
00040  * 
00041  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00042  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00043  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00044  * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00045  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00046  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00047  * 
00048  * Except as contained in this notice, the name of Red Hat shall not be
00049  * used in advertising or otherwise to promote the sale, use or other dealings
00050  * in this Software without prior written authorization from Red Hat.
00051  *
00052  ******************************************************************************
00053  *
00054  * Copyright (C) 2006  Red Hat, Inc. All rights reserved.
00055  *
00056  * This copyrighted material is made available to anyone wishing to use,
00057  * modify, copy, or redistribute it subject to the terms and conditions of
00058  * the GNU General Public License v.2.  This program is distributed in the
00059  * hope that it will be useful, but WITHOUT ANY WARRANTY expressed or
00060  * implied, including the implied warranties of MERCHANTABILITY or FITNESS
00061  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
00062  * details.  You should have received a copy of the GNU General Public
00063  * License along with this program; if not, write to the Free Software
00064  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00065  * USA. Any Red Hat trademarks that are incorporated in the source code or
00066  * documentation are not subject to the GNU General Public License and may
00067  * only be used or replicated with the express permission of Red Hat, Inc.
00068  *
00069  * Red Hat Author(s): Jason Vas Dias
00070  *                    David Cantrell
00071  *
00072  ******************************************************************************
00073  */
00074 
00075 #ifndef H_NET
00076 #define H_NET
00077 
00078 #include <dhcp_nic.h>
00079 #include <resolv.h>
00080 
00081 #define MAX_DNS_SERVERS         (MAXNS)
00082 
00083 typedef
00084 enum pump_defs_e
00085 {
00086     PUMP_INTFINFO_HAS_IP         = 1,
00087     PUMP_INTFINFO_HAS_IPV4_IP    = (1<<1),
00088     PUMP_INTFINFO_HAS_IPV6_IP    = (1<<2),
00089     PUMP_INTFINFO_HAS_IPV6_PREFIX= (1<<3),
00090     PUMP_INTFINFO_HAS_NETMASK    = (1<<4), 
00091     PUMP_INTFINFO_HAS_BROADCAST  = (1<<5),
00092     PUMP_INTFINFO_HAS_NETWORK    = (1<<6),
00093     PUMP_INTFINFO_HAS_MTU        = (1<<7),
00094     PUMP_INTFINFO_HAS_NEXTSERVER = (1<<8),
00095     PUMP_INTFINFO_HAS_BOOTFILE   = (1<<9),
00096     /* room for more ... */
00097     PUMP_NETINFO_HAS_DNS         = (1<<16),
00098     PUMP_NETINFO_HAS_DOMAIN      = (1<<17),
00099     PUMP_NETINFO_HAS_GATEWAY     = (1<<18),
00100     PUMP_NETINFO_HAS_HOSTNAME    = (1<<19)
00101 }   pump_defs_t;
00102 
00103 /**
00104  * pump struct pumpNetIntf stripped down to fields
00105  * actually used by modern anaconda - plus some new 
00106  * fields.
00107  *
00108  * Code which uses any of the type ip_addr_t fields, 
00109  * that were type 'struct in_addr', now need to check
00110  * the fields' .sa_family and deal with either AF_INET
00111  * or AF_INET6 addresses (ip_addr_t is cast compatible 
00112  * with 'struct sockaddr_in' and 'struct sockaddr_in6').
00113  */
00114 struct pumpNetIntf 
00115 {
00116     char device[IF_NAMESIZE];
00117 
00118     ip_addr_t 
00119         ip, ipv4, ipv6, netmask, broadcast, network,  
00120         gateway, nextServer, dnsServers[MAX_DNS_SERVERS];   
00121 
00122     int set, mtu, numDns, 
00123         ipv6_prefixlen;                   /**< set this if 'ip' is IPv6
00124                                            *   to set subnet prefix length
00125                                            */
00126     char * bootFile, * hostname, * domain;/**< dynamically allocated */
00127     
00128     NLH_t     nh;                         /**< the libdhcp NIC Library Handle */    
00129     
00130     DHCP_nic *dhcp_nic;                   /**< the libdhcp DHCP 
00131                                            *   Network Interface Configuration.
00132                                            */    
00133 };
00134 
00135 
00136 extern char * pumpSetupInterface(struct pumpNetIntf * ifx);
00137 
00138 /* int pumpSetupDefaultGateway( struct in_addr * gw ) ;
00139  *
00140  * this is now done by pumpSetupInterface
00141  * if (intf.set & PUMP_NETINFO_HAS_GATEWAY)
00142  * (we need an interface to set the default gateway on).
00143  */
00144 
00145 /**
00146  * pump's pumpDhcpClassRun function.
00147  * The prototype is changed slightly to pass in libdhcp
00148  * control parameters and remove parameters not used
00149  * by anaconda.
00150  */
00151 extern char * pumpDhcpClassRun
00152 (
00153     struct pumpNetIntf * ifx,           /**< DHCP configuration to be stored here
00154                                          * 'ifx->device' must be set to the name of
00155                                          * the interface to configure.
00156                                          */ 
00157     char * hostname,                    /**< DHCP 'host-name' option to send */
00158     char * vendor_class,                /**< DHCP 'vendor-class-identifier' to send */
00159     DHCP_Preference dhcp_preference,    /**< DHCP policy - see dhcp_nic.h */
00160     LIBDHCP_Capability dhcp_capability, /**< DHCP policy - see libdhcp.h  */    
00161     time_t timeout,                     /**< time in seconds each client has to obtain lease */
00162     void (*logger)(void*,int,char*,va_list),/**< in case you want to do something with
00163                                          * libdhcp log / debug messages - otherwise,
00164                                          * pass in as NULL.
00165                                          */
00166     int max_log_priority                /**< if a logger was specified, the maximum
00167                                          *   priority to log (same as syslog priority).
00168                                          */
00169 );
00170 
00171 extern char * pumpDisableInterface(char * device);
00172 
00173 #endif

Generated on Mon Aug 14 17:25:56 2006 for libdhcp by  doxygen 1.4.7