1/* 2 * trygetif.c - test program for getif.c 3 */ 4 5#include <sys/types.h> 6#include <sys/socket.h> 7 8#if defined(SUNOS) || defined(SVR4) 9#include <sys/sockio.h> 10#endif 11
| 1/* 2 * trygetif.c - test program for getif.c 3 */ 4 5#include <sys/types.h> 6#include <sys/socket.h> 7 8#if defined(SUNOS) || defined(SVR4) 9#include <sys/sockio.h> 10#endif 11
|
| 12#ifdef _AIX32 13#include <sys/time.h> /* for struct timeval in net/if.h */ 14#endif
|
12#include <net/if.h> /* for struct ifreq */ 13#include <netinet/in.h> 14#include <arpa/inet.h> /* inet_ntoa */ 15 16#include <netdb.h> 17#include <stdio.h> 18#include <ctype.h> 19#include <errno.h> 20 21#include "getif.h" 22 23int debug = 0; 24char *progname; 25
| 15#include <net/if.h> /* for struct ifreq */ 16#include <netinet/in.h> 17#include <arpa/inet.h> /* inet_ntoa */ 18 19#include <netdb.h> 20#include <stdio.h> 21#include <ctype.h> 22#include <errno.h> 23 24#include "getif.h" 25 26int debug = 0; 27char *progname; 28
|
| 29void
|
26main(argc, argv)
| 30main(argc, argv)
|
| 31 int argc;
|
27 char **argv; 28{ 29 struct hostent *hep;
| 32 char **argv; 33{ 34 struct hostent *hep;
|
30 struct sockaddr ea; /* Ethernet address */
| |
31 struct sockaddr_in *sip; /* Interface address */ 32 struct ifreq *ifr; 33 struct in_addr dst_addr; 34 struct in_addr *dap;
| 35 struct sockaddr_in *sip; /* Interface address */ 36 struct ifreq *ifr; 37 struct in_addr dst_addr; 38 struct in_addr *dap;
|
35 int i, s;
| 39 int s;
|
36 37 progname = argv[0]; /* for report */ 38 39 dap = NULL; 40 if (argc > 1) { 41 dap = &dst_addr;
| 40 41 progname = argv[0]; /* for report */ 42 43 dap = NULL; 44 if (argc > 1) { 45 dap = &dst_addr;
|
42 if (inet_aton(argv[1], &dst_addr) == 0) {
| 46 if (isdigit(argv[1][0])) 47 dst_addr.s_addr = inet_addr(argv[1]); 48 else {
|
43 hep = gethostbyname(argv[1]); 44 if (!hep) { 45 printf("gethostbyname(%s)\n", argv[1]); 46 exit(1); 47 } 48 memcpy(&dst_addr, hep->h_addr, sizeof(dst_addr)); 49 } 50 }
--- 16 unchanged lines hidden --- | 49 hep = gethostbyname(argv[1]); 50 if (!hep) { 51 printf("gethostbyname(%s)\n", argv[1]); 52 exit(1); 53 } 54 memcpy(&dst_addr, hep->h_addr, sizeof(dst_addr)); 55 } 56 }
--- 16 unchanged lines hidden --- |