00001 #include <sys/types.h>
00002 #include <unistd.h>
00003 #include <string.h>
00004 #include <stdio.h>
00005
00006 #include <pump.h>
00007
00008 void logger(void *arg, int priority, char *fmt, va_list va)
00009 {
00010 libdhcp_stderr_logger(0, priority, fmt, va);
00011 }
00012
00013 int main( int argc, char **argv, char **envp)
00014 {
00015 struct pumpNetIntf ifx;
00016
00017 memset(&ifx, '\0', sizeof(ifx));
00018
00019 strcpy(&(ifx.device[0]),"eth0");
00020
00021 char *s =
00022 pumpDhcpClassRun
00023 (
00024 &ifx,
00025 0L, 0L, 0, 0,
00026 10,
00027 logger,
00028 LOG_DEBUG
00029 ),
00030 buf[64];
00031
00032 if( s != 0L )
00033 {
00034 printf("%s\n",s);
00035 return 1;
00036 }
00037
00038 if( ifx.set & PUMP_INTFINFO_HAS_IP )
00039 printf("ip: %s\n",
00040 ip_text_addr(&(ifx.ip),buf,64)
00041 );
00042
00043 if( ifx.set & PUMP_INTFINFO_HAS_IPV4_IP )
00044 printf("ipv4: %s\n",
00045 ip_text_addr(&(ifx.ipv4),buf,64)
00046 );
00047
00048 if( ifx.set & PUMP_INTFINFO_HAS_IPV6_IP )
00049 printf("ipv6: %s\n",
00050 ip_text_addr(&(ifx.ipv6),buf,64)
00051 );
00052
00053 if( ifx.set & PUMP_INTFINFO_HAS_IPV6_PREFIX )
00054 printf("ipv6_prefixlen: %d\n",
00055 ifx.ipv6_prefixlen
00056 );
00057
00058 if( ifx.set & PUMP_INTFINFO_HAS_NETMASK )
00059 printf("netmask: %s\n",
00060 ip_text_addr(&(ifx.netmask),buf,64)
00061 );
00062
00063 if( ifx.set & PUMP_INTFINFO_HAS_NETWORK )
00064 printf("network: %s\n",
00065 ip_text_addr(&(ifx.network),buf,64)
00066 );
00067
00068 if( ifx.set & PUMP_INTFINFO_HAS_BROADCAST )
00069 printf("broadcast: %s\n",
00070 ip_text_addr(&(ifx.broadcast),buf,64)
00071 );
00072
00073 if( ifx.set & PUMP_NETINFO_HAS_GATEWAY )
00074 printf("gateway: %s\n",
00075 ip_text_addr(&(ifx.gateway),buf,64)
00076 );
00077
00078 if( ifx.set & PUMP_INTFINFO_HAS_NEXTSERVER )
00079 printf("nextServer: %s\n",
00080 ip_text_addr(&(ifx.nextServer),buf,64)
00081 );
00082
00083 if( ifx.set & PUMP_INTFINFO_HAS_MTU )
00084 printf("mtu: %d\n",
00085 ifx.mtu
00086 );
00087
00088 if( ifx.set & PUMP_NETINFO_HAS_DNS )
00089 {
00090 if( ifx.domain )
00091 printf("domain: %s\n",
00092 ifx.domain
00093 );
00094 if( ifx.numDns )
00095 {
00096 int i;
00097 for(i=0; i < ifx.numDns; i++)
00098 printf("nameserver: %s\n",
00099 ip_text_addr(&(ifx.dnsServers[i]),buf,64)
00100 );
00101 }
00102 }
00103
00104 if( ifx.set & PUMP_NETINFO_HAS_HOSTNAME )
00105 {
00106 printf("hostname: %s\n",
00107 ifx.hostname
00108 );
00109 }
00110
00111 if( ifx.set & PUMP_INTFINFO_HAS_BOOTFILE )
00112 {
00113 printf("bootFile: %s\n",
00114 ifx.bootFile
00115 );
00116 }
00117
00118 if( (s = pumpSetupInterface( &ifx )) != 0 )
00119 {
00120 printf("pumpSetupInterface failed: %s\n", s);
00121 return 1;
00122 }
00123
00124 return 0;
00125 }
00126