From: Emmanuel D. <ma...@us...> - 2004-10-29 13:53:42
|
Update of /cvsroot/ipsec-tools/ipsec-tools/src/racoon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18280 Modified Files: kmpstat.c Log Message: Resolv DNS addresses in the vpn-connect/vpn-disconnect target Index: kmpstat.c =================================================================== RCS file: /cvsroot/ipsec-tools/ipsec-tools/src/racoon/kmpstat.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- kmpstat.c 29 Oct 2004 13:43:22 -0000 1.10 +++ kmpstat.c 29 Oct 2004 13:53:30 -0000 1.11 @@ -1267,8 +1267,15 @@ dst.sin_family = AF_INET; dst.sin_port = htons(500); /* The port number does not matter */ - if (inet_pton(AF_INET, dstaddr, &dst.sin_addr) != 1) - errx(1, "inet_pton failed"); + if (inet_pton(AF_INET, dstaddr, &dst.sin_addr) != 1) { + struct hostent *host; + + /* Try it as a DNS address */ + if ((host = gethostbyname(dstaddr)) == NULL) + errx(1, "peer cannot be resolved"); + + memcpy(&dst.sin_addr, &host->h_addr, sizeof(dst.sin_addr)); + } if (connect(sock, (struct sockaddr *)&dst, sizeof(dst)) == -1) errx(1, "connect failed"); |