00001 /* @file dhcp4_nic.h 00002 * 00003 * Network Interface Configurator for the ISC DHCP IPv4 client library API. 00004 * 00005 * @author Jason Vas Dias <jvdias@redhat.com> 00006 */ 00007 /* 00008 * Copyright(C) Jason Vas Dias <jvdias@redhat.com> Red Hat Inc. May 2006 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation at 00013 * http://www.fsf.org/licensing/licenses/gpl.txt 00014 * and included in this software distribution as the "LICENSE" file. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 */ 00021 #include <libdhcp.h> 00022 #include <dhcp4_lease.h> 00023 #include <nic.h> 00024 #include <stdarg.h> 00025 00026 /** 00027 * @addtogroup DHCPv4 00028 * @{ 00029 */ 00030 typedef struct dhcpv4_control_s DHCPv4_control; /**< 00031 * The DHCPv4 client control structure. This has more 00032 * fields than the plain LIBDHCP_Control structure, 00033 * and must be obtained by calling dhcpv4_control. 00034 */ 00035 00036 /** 00037 * dhcpv4_control(): returns a new DHCPv4_control structure. 00038 */ 00039 extern 00040 DHCPv4_control* 00041 dhcpv4_control 00042 ( 00043 NLH_t nic_handle, /**< nic library handle - @ref NICH */ 00044 char *eth_if_name, /**< ethernet interface name */ 00045 LIBDHCP_Capability dhc_cap, /**< DHCP capability - @see ::LIBDHCP_Capability */ 00046 time_t timeout, /**< timeout - @see ::LIBDHCP_Control::timeout */ 00047 LIBDHCP_Error_Handler error_handler, /**< error handler - @see ::LIBDHCP_Control::error_handler */ 00048 uint8_t log_level, /**< log_level - @see ::LIBDHCP_Control::log_level */ 00049 ... /**< extra dhclient args - see man 8 dhclient - 00050 * last arg MUST be 0. 00051 */ 00052 ); 00053 00054 /** 00055 * dhcpv4_control_va - dhcpv4_control() that can be called with a va_list. 00056 */ 00057 extern 00058 DHCPv4_control* 00059 dhcpv4_control_va 00060 ( 00061 NLH_t nic_handle, 00062 char *eth_if_name, 00063 LIBDHCP_Capability dhc_cap, 00064 time_t timeout, 00065 LIBDHCP_Error_Handler error_handler, 00066 uint8_t log_level, 00067 va_list dhclient_va 00068 ); 00069 00070 /** 00071 * dhcpv4_control_free( ctl ) : frees all resources associated with ctl. 00072 */ 00073 extern 00074 void dhcpv4_control_free( DHCPv4_control* ); 00075 00076 /** 00077 * DHCPv4_nic: structure representing the network interface configuration 00078 * parameters associated with a DHCPv4_lease. 00079 */ 00080 typedef 00081 struct dhcp4_nic_s 00082 { 00083 NLH_t nh; /**< NIC library handle */ 00084 NIC_t nic; /**< Network Interface structure */ 00085 IPaddr_list_t address_list; /**< list of lease addresses */ 00086 IProute_list_t route_list; /**< list of lease routes */ 00087 IPaddr_list_t dns_list; /**< list of resolver DNS servers */ 00088 char *search_list; /**< DNS resolver search list */ 00089 char *host_name; /**< lease host-name option */ 00090 DHCPv4_lease *lease; /**< the DHCPv4_lease structure */ 00091 } DHCPv4_nic; 00092 00093 extern 00094 DHCPv4_nic *do_dhcpv4( DHCPv4_control * ); 00095 00096 extern 00097 NIC_Res_t dhcpv4_nic(NLH_t, DHCPv4_nic * ); 00098 00099 extern 00100 uint32_t dhcpv4_mtu_option( DHCPv4_control * ); 00101 00102 extern 00103 int dhcp4_process_lease(DHCPv4_control *); 00104 00105 extern 00106 DHCPv4_nic *dhcp4_set_lease(DHCPv4_control *, DHCPv4_lease *); 00107 00108 extern 00109 void dhcp4_nic_option_handler 00110 ( DHCPv4_option *option, 00111 void *arg /* must be a DHCPv4_control */ 00112 ); 00113 00114 extern 00115 int dhcp4_nic_callback 00116 ( LIBDHCP_Control *control, /* must be a DHCPv4_control */ 00117 DHCP_State state, 00118 void *arg 00119 ); 00120 00121 /**@}*/