From ae1912cb0d494b48d514d937826c9fe83ec96c4d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 29 Dec 1999 14:20:26 +0000 Subject: Initial revision --- lib/if2ip.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 lib/if2ip.c (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c new file mode 100644 index 000000000..f8a37bb12 --- /dev/null +++ b/lib/if2ip.c @@ -0,0 +1,110 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Curl. + * + * The Initial Developer of the Original Code is Daniel Stenberg. + * + * Portions created by the Initial Developer are Copyright (C) 1998. + * All Rights Reserved. + * + * ------------------------------------------------------------ + * Main author: + * - Daniel Stenberg + * + * http://curl.haxx.nu + * + * $Source$ + * $Revision$ + * $Date$ + * $Author$ + * $State$ + * $Locker$ + * + * ------------------------------------------------------------ + ****************************************************************************/ + +#include +#include +#include + +#include "setup.h" + +#ifdef HAVE_UNISTD_H +#include +#endif + +#if ! defined(WIN32) && ! defined(__BEOS__) + +#include +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +#include +#ifdef HAVE_NET_IF_H +#include +#endif +#include + +/* -- if2ip() -- */ +#ifdef HAVE_NETDB_H +#include +#endif + +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif + +#define SYS_ERROR -1 + +char *if2ip(char *interface) +{ + int dummy; + char *ip=NULL; + + if(!interface) + return NULL; + + dummy = socket(AF_INET, SOCK_STREAM, 0); + if (SYS_ERROR == dummy) { + return NULL; + } + else { + struct ifreq req; + memset(&req, 0, sizeof(req)); + strcpy(req.ifr_name, interface); + req.ifr_addr.sa_family = AF_INET; + if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { + return NULL; + } + else { + struct in_addr in; + + struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr; + memcpy(&in, &(s->sin_addr.s_addr), sizeof(in)); + ip = (char *)strdup(inet_ntoa(in)); + } + close(dummy); + } + return ip; +} + +/* -- end of if2ip() -- */ +#else +#define if2ip(x) NULL +#endif -- cgit v1.2.1 From 3ad1df668e441898c654d310b1b271a6b5e5a623 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 25 May 2000 15:18:34 +0000 Subject: AIX wants sys/time.h included --- lib/if2ip.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index f8a37bb12..e9b8a4955 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -66,6 +66,10 @@ #include #endif +#include HAVE_SYS_TIME_H +#include +#endif + #ifdef HAVE_SYS_SOCKIO_H #include #endif -- cgit v1.2.1 From 784e9406ae4a8d5feffc3c56a72f66674538e5d1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 26 May 2000 13:57:11 +0000 Subject: silly mistake corrected --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index e9b8a4955..5fa70a68c 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -66,7 +66,7 @@ #include #endif -#include HAVE_SYS_TIME_H +#ifdef HAVE_SYS_TIME_H #include #endif -- cgit v1.2.1 From a0ce95e155de68bd5a088a7a539f45aa7134b00b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 29 May 2000 22:51:13 +0000 Subject: David LeBlanc's fixes! --- lib/if2ip.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 5fa70a68c..557b6fb8c 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -74,9 +74,13 @@ #include #endif +#ifdef HAVE_INET_NTOA_R +#include "inet_ntoa_r.h" +#endif + #define SYS_ERROR -1 -char *if2ip(char *interface) +char *if2ip(char *interface, char *buf, int buf_size) { int dummy; char *ip=NULL; @@ -101,7 +105,12 @@ char *if2ip(char *interface) struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr; memcpy(&in, &(s->sin_addr.s_addr), sizeof(in)); - ip = (char *)strdup(inet_ntoa(in)); +#if defined(HAVE_INET_NTOA_R) + ip = inet_ntoa_r(in,buf,buf_size); +#else + ip = strncpy(buf,inet_ntoa(in),buf_size); + ip[buf_size - 1] = 0; +#endif } close(dummy); } -- cgit v1.2.1 From 1ef3600a0731fef8f59563a1e49981f1b64b9746 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 20 Jun 2000 15:31:26 +0000 Subject: haxx.nu => haxx.se --- lib/if2ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 557b6fb8c..065108efa 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -24,9 +24,9 @@ * * ------------------------------------------------------------ * Main author: - * - Daniel Stenberg + * - Daniel Stenberg * - * http://curl.haxx.nu + * http://curl.haxx.se * * $Source$ * $Revision$ -- cgit v1.2.1 From a2f045451f5a296059e2a2a8b9c15ca804385170 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 4 Aug 2000 11:27:57 +0000 Subject: moved an include file further up to make AIX 3 more happy --- lib/if2ip.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 065108efa..420b6df2c 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -56,6 +56,11 @@ #include #endif #include + +#ifdef HAVE_SYS_TIME_H +/* This must be before net/if.h for AIX 3.2 to enjoy life */ +#include +#endif #ifdef HAVE_NET_IF_H #include #endif @@ -66,10 +71,6 @@ #include #endif -#ifdef HAVE_SYS_TIME_H -#include -#endif - #ifdef HAVE_SYS_SOCKIO_H #include #endif -- cgit v1.2.1 From d4731b70505d308064e85bfa1ea1f88904442af2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 23 Aug 2000 07:23:42 +0000 Subject: Albert Chin-A-Young's fixes --- lib/if2ip.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 420b6df2c..ede5cf08c 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -50,12 +50,19 @@ #if ! defined(WIN32) && ! defined(__BEOS__) +#ifdef NEED_REENTRANT +#define _REENTRANT +#endif + +#ifdef HAVE_SYS_SOCKET_H #include +#endif +#ifdef HAVE_NETINET_IN_H #include +#endif #ifdef HAVE_ARPA_INET_H #include #endif -#include #ifdef HAVE_SYS_TIME_H /* This must be before net/if.h for AIX 3.2 to enjoy life */ @@ -75,7 +82,7 @@ #include #endif -#ifdef HAVE_INET_NTOA_R +#ifndef HAVE_INET_NTOA_R_DECL #include "inet_ntoa_r.h" #endif -- cgit v1.2.1 From 1b1f143cd65cb86138e3083790d89f959e3ecc87 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 24 Aug 2000 12:33:16 +0000 Subject: hostname and large file support added --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index ede5cf08c..25b2c40c2 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -82,7 +82,7 @@ #include #endif -#ifndef HAVE_INET_NTOA_R_DECL +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) #include "inet_ntoa_r.h" #endif -- cgit v1.2.1 From b6e18f2f665f16910c04cb52bdc7b90270ab7c9b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 24 Aug 2000 14:26:33 +0000 Subject: #include "setup.h" moved first of all includes --- lib/if2ip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 25b2c40c2..bba8161c0 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -38,11 +38,12 @@ * ------------------------------------------------------------ ****************************************************************************/ +#include "setup.h" + #include #include #include -#include "setup.h" #ifdef HAVE_UNISTD_H #include -- cgit v1.2.1 From 24dee483e9e925c2ab79dd582f70c9a55ab9ba4d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 3 Jan 2001 09:29:33 +0000 Subject: dual-license fix --- lib/if2ip.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index bba8161c0..06be25d8a 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,38 +5,21 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * The contents of this file are subject to the Mozilla Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ + * Copyright (C) 2000, Daniel Stenberg, , et al. * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - * License for the specific language governing rights and limitations - * under the License. + * In order to be useful for every potential user, curl and libcurl are + * dual-licensed under the MPL and the MIT/X-derivate licenses. * - * The Original Code is Curl. + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the MPL or the MIT/X-derivate + * licenses. You may pick one of these licenses. * - * The Initial Developer of the Original Code is Daniel Stenberg. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. * - * Portions created by the Initial Developer are Copyright (C) 1998. - * All Rights Reserved. - * - * ------------------------------------------------------------ - * Main author: - * - Daniel Stenberg - * - * http://curl.haxx.se - * - * $Source$ - * $Revision$ - * $Date$ - * $Author$ - * $State$ - * $Locker$ - * - * ------------------------------------------------------------ - ****************************************************************************/ + * $Id$ + *****************************************************************************/ #include "setup.h" -- cgit v1.2.1 From 4031104404c6ceed5e57134125dcdb6cac51c564 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Jan 2001 10:11:41 +0000 Subject: Internal symbols that aren't static are now prefixed with 'Curl_' --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 06be25d8a..dc3138a01 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -72,7 +72,7 @@ #define SYS_ERROR -1 -char *if2ip(char *interface, char *buf, int buf_size) +char *Curl_if2ip(char *interface, char *buf, int buf_size) { int dummy; char *ip=NULL; -- cgit v1.2.1 From 29bcba9a9075265cefd967a1dfdbac50a6958245 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Jan 2001 14:44:05 +0000 Subject: Ingo Ralf Blum's cygwin fixes --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index dc3138a01..87ead2b9e 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -32,7 +32,7 @@ #include #endif -#if ! defined(WIN32) && ! defined(__BEOS__) +#if ! defined(WIN32) && ! defined(__BEOS__) && !defined(__CYGWIN32__) #ifdef NEED_REENTRANT #define _REENTRANT -- cgit v1.2.1 From 952b3a2c0ff97043a385c00d530d88114f8732e4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Mar 2001 15:19:36 +0000 Subject: added memdebug.h include --- lib/if2ip.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 87ead2b9e..0acc3d6c8 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -70,6 +70,11 @@ #include "inet_ntoa_r.h" #endif +/* The last #include file should be: */ +#ifdef MALLOCDEBUG +#include "memdebug.h" +#endif + #define SYS_ERROR -1 char *Curl_if2ip(char *interface, char *buf, int buf_size) -- cgit v1.2.1 From 455663ba5ecdedd6d338272bdc93ff9670bcb702 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Mar 2001 15:44:38 +0000 Subject: corrected the close to sclose() so that the memdebug stuff works --- lib/if2ip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 0acc3d6c8..01076c9a0 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -95,6 +95,7 @@ char *Curl_if2ip(char *interface, char *buf, int buf_size) strcpy(req.ifr_name, interface); req.ifr_addr.sa_family = AF_INET; if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { + sclose(dummy); return NULL; } else { @@ -109,7 +110,7 @@ char *Curl_if2ip(char *interface, char *buf, int buf_size) ip[buf_size - 1] = 0; #endif } - close(dummy); + sclose(dummy); } return ip; } -- cgit v1.2.1 From 77f34915ce25a22b2f2742ba69ac76093376dc94 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 31 May 2001 07:03:04 +0000 Subject: removed _REENTRANT define --- lib/if2ip.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 01076c9a0..1e6a88f0d 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -34,10 +34,6 @@ #if ! defined(WIN32) && ! defined(__BEOS__) && !defined(__CYGWIN32__) -#ifdef NEED_REENTRANT -#define _REENTRANT -#endif - #ifdef HAVE_SYS_SOCKET_H #include #endif -- cgit v1.2.1 From 5b6640960a3d2a2df7d48342d3bf60d3656aaac7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 6 Aug 2001 12:22:48 +0000 Subject: VMS adjustments. The IOCTL_3_ARGS #define used now should be moved to become a configure checked one. --- lib/if2ip.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 1e6a88f0d..261de990a 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -66,6 +66,11 @@ #include "inet_ntoa_r.h" #endif +#ifdef VMS +#define IOCTL_3_ARGS +#include +#endif + /* The last #include file should be: */ #ifdef MALLOCDEBUG #include "memdebug.h" @@ -90,7 +95,11 @@ char *Curl_if2ip(char *interface, char *buf, int buf_size) memset(&req, 0, sizeof(req)); strcpy(req.ifr_name, interface); req.ifr_addr.sa_family = AF_INET; +#ifdef IOCTL_3_ARGS + if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { +#else if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { +#endif sclose(dummy); return NULL; } -- cgit v1.2.1 From 6147879837a53d22c9be04e7a4fc315a297ba2b3 Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Fri, 7 Sep 2001 04:01:32 +0000 Subject: Added formatting sections for emacs and vim --- lib/if2ip.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 261de990a..92905ccfd 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -124,3 +124,11 @@ char *Curl_if2ip(char *interface, char *buf, int buf_size) #else #define if2ip(x) NULL #endif + +/* + * local variables: + * eval: (load-file "../curl-mode.el") + * end: + * vim600: et sw=2 ts=2 sts=2 tw=78 fdm=marker + * vim<600: et sw=2 ts=2 sts=2 tw=78 + */ -- cgit v1.2.1 From 8e91d5de8e4e17ce3d4936cc91171d09726e7bb3 Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Thu, 11 Oct 2001 09:32:19 +0000 Subject: looks nicer and is better compatible with older vim versions --- lib/if2ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 92905ccfd..b70ed35e4 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -129,6 +129,6 @@ char *Curl_if2ip(char *interface, char *buf, int buf_size) * local variables: * eval: (load-file "../curl-mode.el") * end: - * vim600: et sw=2 ts=2 sts=2 tw=78 fdm=marker - * vim<600: et sw=2 ts=2 sts=2 tw=78 + * vim600: fdm=marker + * vim: et sw=2 ts=2 sts=2 tw=78 */ -- cgit v1.2.1 From 974f314f5785156af6983675aeb28313cc8ba2ea Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 19 Mar 2002 07:54:55 +0000 Subject: copyright string (year) update --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index b70ed35e4..17a086f0b 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2000, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. * * In order to be useful for every potential user, curl and libcurl are * dual-licensed under the MPL and the MIT/X-derivate licenses. -- cgit v1.2.1 From ba4e69bebc8f7f32f3bc7faa1e13e7580754075b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 3 Sep 2002 11:52:59 +0000 Subject: updated source code boilerplate/header --- lib/if2ip.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 17a086f0b..0d91782e5 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -1,4 +1,4 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | @@ -7,19 +7,19 @@ * * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. * - * In order to be useful for every potential user, curl and libcurl are - * dual-licensed under the MPL and the MIT/X-derivate licenses. - * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the MPL or the MIT/X-derivate - * licenses. You may pick one of these licenses. + * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * * $Id$ - *****************************************************************************/ + ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From f26a338a54e04d0a6907f5d2479d8b0fa9daf297 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 16 Jan 2003 21:08:12 +0000 Subject: copyright year update in the source header --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 0d91782e5..05ed0caa5 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From a7c72b7abf1213c471f3fd11e6b8e3a37d526f60 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 29 Jan 2003 10:14:20 +0000 Subject: removed the local variables for emacs and vim, use the new sample.emacs way for emacs, and vim users should provide a similar non-polluting style --- lib/if2ip.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 05ed0caa5..5975a3ad2 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -124,11 +124,3 @@ char *Curl_if2ip(char *interface, char *buf, int buf_size) #else #define if2ip(x) NULL #endif - -/* - * local variables: - * eval: (load-file "../curl-mode.el") - * end: - * vim600: fdm=marker - * vim: et sw=2 ts=2 sts=2 tw=78 - */ -- cgit v1.2.1 From 8f809e2a9329c419ac184d658b58902ace51e97b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 28 Feb 2003 13:11:10 +0000 Subject: James Bursa made it compile on RISC OS as well. --- lib/if2ip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 5975a3ad2..988e5924a 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -32,7 +32,8 @@ #include #endif -#if ! defined(WIN32) && ! defined(__BEOS__) && !defined(__CYGWIN32__) +#if ! defined(WIN32) && ! defined(__BEOS__) && !defined(__CYGWIN32__) && \ + ! defined(__riscos__) #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From 07dd067f731afc7e0a08240cc92a4b4f27163c2d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 23 May 2003 06:43:14 +0000 Subject: DJGPP fix by Gisle Vanem --- lib/if2ip.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 988e5924a..d4cfa5181 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -77,6 +77,10 @@ #include "memdebug.h" #endif +#ifdef DJGPP +#define IOCTL_3_ARGS +#endif + #define SYS_ERROR -1 char *Curl_if2ip(char *interface, char *buf, int buf_size) -- cgit v1.2.1 From 308bc9d919d57388f269c473778ea7f6a331d1c5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 26 Jun 2003 11:22:12 +0000 Subject: use CURLDEBUG instead of MALLOCDEBUG for preprocessor conditions --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index d4cfa5181..07f30986b 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -73,7 +73,7 @@ #endif /* The last #include file should be: */ -#ifdef MALLOCDEBUG +#ifdef CURLDEBUG #include "memdebug.h" #endif -- cgit v1.2.1 From 053f6c85efd0bf698f73343989474d672d0563a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 7 Jan 2004 09:19:33 +0000 Subject: updated year in the copyright string --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 07f30986b..249be7ce2 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From a275365c72fb628c8ea1e246aac02f6ebcb2b20b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Jan 2004 07:09:28 +0000 Subject: Avoid Curl_if2ip() on Interix as well. Fix by Rodney. --- lib/if2ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 249be7ce2..627422b94 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -32,8 +32,8 @@ #include #endif -#if ! defined(WIN32) && ! defined(__BEOS__) && !defined(__CYGWIN32__) && \ - ! defined(__riscos__) +#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN32__) && \ + !defined(__riscos__) && !defined(__INTERIX) #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From 4d17d6876e4b2f08380812c4ec113073b0a14639 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 29 Jan 2004 13:56:45 +0000 Subject: Dan Fandrich's cleanup patch to make pedantic compiler options cause less warnings. Minor edits by me. --- lib/if2ip.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 627422b94..84785a580 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -72,6 +72,8 @@ #include #endif +#include "if2ip.h" + /* The last #include file should be: */ #ifdef CURLDEBUG #include "memdebug.h" -- cgit v1.2.1 From 7e45a1ac5310cba784fe4434e41f6ad276976d80 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 29 Jan 2004 15:35:42 +0000 Subject: moved the definitions of IOCTL_3_ARGS to setup.h --- lib/if2ip.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 84785a580..0dd403ac9 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -27,7 +27,6 @@ #include #include - #ifdef HAVE_UNISTD_H #include #endif @@ -68,7 +67,6 @@ #endif #ifdef VMS -#define IOCTL_3_ARGS #include #endif @@ -79,10 +77,6 @@ #include "memdebug.h" #endif -#ifdef DJGPP -#define IOCTL_3_ARGS -#endif - #define SYS_ERROR -1 char *Curl_if2ip(char *interface, char *buf, int buf_size) -- cgit v1.2.1 From b84eaff1d57754e9d154fa7fc7bf941c9e430a31 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 2 Feb 2004 14:49:54 +0000 Subject: set the 'retry' bit to TRUE when the connection is about to be retried, this allows the HTTP code to *not* return a failure just because no data has been received from the server --- lib/if2ip.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 0dd403ac9..299be75dd 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -51,7 +51,9 @@ #ifdef HAVE_NET_IF_H #include #endif +#ifdef HAVE_SYS_IOCTL_H #include +#endif /* -- if2ip() -- */ #ifdef HAVE_NETDB_H -- cgit v1.2.1 From 5b55f9ecb34a00af236b2275ffa9adab492a93b6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 17 Mar 2004 12:46:42 +0000 Subject: =?UTF-8?q?G=FCnter=20Knauf's=20NetWare=20changes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/if2ip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 299be75dd..63a634099 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -32,7 +32,7 @@ #endif #if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN32__) && \ - !defined(__riscos__) && !defined(__INTERIX) + !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) #ifdef HAVE_SYS_SOCKET_H #include @@ -125,5 +125,8 @@ char *Curl_if2ip(char *interface, char *buf, int buf_size) /* -- end of if2ip() -- */ #else -#define if2ip(x) NULL +char *Curl_if2ip(char *interface, char *buf, int buf_size) +{ + return NULL; +} #endif -- cgit v1.2.1 From b2c290e40e73a8c2b7a0a15a967c1abe4d603382 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 5 May 2004 13:42:23 +0000 Subject: Gisle-fix: constified the 'interface' argument. --- lib/if2ip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 63a634099..94de81f8a 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -81,7 +81,7 @@ #define SYS_ERROR -1 -char *Curl_if2ip(char *interface, char *buf, int buf_size) +char *Curl_if2ip(const char *interface, char *buf, int buf_size) { int dummy; char *ip=NULL; @@ -125,8 +125,11 @@ char *Curl_if2ip(char *interface, char *buf, int buf_size) /* -- end of if2ip() -- */ #else -char *Curl_if2ip(char *interface, char *buf, int buf_size) +char *Curl_if2ip(const char *interface, char *buf, int buf_size) { + (void) interface; + (void) buf; + (void) buf_size; return NULL; } #endif -- cgit v1.2.1 From bbafb2eb27954c34967f91c705e74cc0c186970d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 11 May 2004 11:30:23 +0000 Subject: curl_global_init_mem() allows the memory functions to be replaced. memory.h is included everywhere for this. --- lib/if2ip.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 94de81f8a..b816d246f 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -73,11 +73,10 @@ #endif #include "if2ip.h" +#include "memory.h" /* The last #include file should be: */ -#ifdef CURLDEBUG #include "memdebug.h" -#endif #define SYS_ERROR -1 -- cgit v1.2.1 From c39858aac0584716282dcb097ce9d972b43dbcb2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 24 Jun 2004 07:43:48 +0000 Subject: Source cleanups. The major one being that we now _always_ use a Curl_addrinfo linked list for name resolved data, even on hosts/systems with only IPv4 stacks as this simplifies a lot of code. --- lib/if2ip.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index b816d246f..237d1f758 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -1,8 +1,8 @@ /*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. @@ -10,7 +10,7 @@ * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. - * + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. @@ -64,7 +64,7 @@ #include #endif -#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) #include "inet_ntoa_r.h" #endif @@ -84,7 +84,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) { int dummy; char *ip=NULL; - + if(!interface) return NULL; -- cgit v1.2.1 From 4af08a19f85c577d9b1f2df892c82e34e473f31d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 30 Jun 2004 11:48:19 +0000 Subject: passing in a very long interface name could make a buffer overflow --- lib/if2ip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 237d1f758..b167b8df6 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -94,8 +94,11 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) } else { struct ifreq req; + size_t len = strlen(interface); memset(&req, 0, sizeof(req)); - strcpy(req.ifr_name, interface); + if(len >= sizeof(req.ifr_name)) + return NULL; /* this can't be a fine interface name */ + memcpy(req.ifr_name, interface, len+1); req.ifr_addr.sa_family = AF_INET; #ifdef IOCTL_3_ARGS if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { -- cgit v1.2.1 From 6c5ea2af27e57268b5be3fce5b9d1164c67d0cce Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 6 Oct 2004 06:58:42 +0000 Subject: untabify --- lib/if2ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index b167b8df6..96ecc5348 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -68,7 +68,7 @@ #include "inet_ntoa_r.h" #endif -#ifdef VMS +#ifdef VMS #include #endif @@ -100,7 +100,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) return NULL; /* this can't be a fine interface name */ memcpy(req.ifr_name, interface, len+1); req.ifr_addr.sa_family = AF_INET; -#ifdef IOCTL_3_ARGS +#ifdef IOCTL_3_ARGS if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { #else if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { -- cgit v1.2.1 From 24d47a6e07304cf0921f2d30734b3c64360773c3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Nov 2004 10:12:22 +0000 Subject: Paul Nolan fix to make libcurl build nicely on Windows CE --- lib/if2ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 96ecc5348..8f0a07782 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -127,9 +127,9 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) /* -- end of if2ip() -- */ #else -char *Curl_if2ip(const char *interface, char *buf, int buf_size) +char *Curl_if2ip(const char *interf, char *buf, int buf_size) { - (void) interface; + (void) interf; (void) buf; (void) buf_size; return NULL; -- cgit v1.2.1 From ec4e653c6ffba1948a507c5a7918022dd4e6f7ce Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 14 Mar 2005 15:51:10 +0000 Subject: hushing up more warnings --- lib/if2ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 8f0a07782..db28e4aad 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -31,6 +31,8 @@ #include #endif +#include "if2ip.h" + #if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN32__) && \ !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) @@ -55,7 +57,6 @@ #include #endif -/* -- if2ip() -- */ #ifdef HAVE_NETDB_H #include #endif @@ -72,7 +73,6 @@ #include #endif -#include "if2ip.h" #include "memory.h" /* The last #include file should be: */ -- cgit v1.2.1 From efaf6886505cd29084af05aa06edc19fd71bdfe9 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 15 Mar 2005 21:00:46 +0000 Subject: Fixed ftp support with uClibc due to differing inet_ntoa_r() behaviour. --- lib/if2ip.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index db28e4aad..966032506 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -65,10 +65,6 @@ #include #endif -#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) -#include "inet_ntoa_r.h" -#endif - #ifdef VMS #include #endif @@ -113,12 +109,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr; memcpy(&in, &(s->sin_addr.s_addr), sizeof(in)); -#if defined(HAVE_INET_NTOA_R) - ip = inet_ntoa_r(in,buf,buf_size); -#else - ip = strncpy(buf,inet_ntoa(in),buf_size); - ip[buf_size - 1] = 0; -#endif + ip = Curl_inet_ntop(s->sin_family, &in, buf, buf_size); } sclose(dummy); } -- cgit v1.2.1 From bf87d13f5b94aed8876d2c950faeadf7e6636128 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 16 Mar 2005 02:25:12 +0000 Subject: Fixed some compiler warnings I should have noticed before. --- lib/if2ip.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 966032506..70e93634c 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -69,6 +69,7 @@ #include #endif +#include "inet_ntop.h" #include "memory.h" /* The last #include file should be: */ -- cgit v1.2.1 From ab4086bc244bf3267976e9f0193e5ed4430190d8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 31 Mar 2005 07:02:02 +0000 Subject: Updated the copyright year since changes have been this year. --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 70e93634c..f2ecfdc31 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From 37a547842b763853f1d4c7c759ae92b8b91654db Mon Sep 17 00:00:00 2001 From: Marty Kuhrt Date: Fri, 8 Apr 2005 05:01:40 +0000 Subject: cast the call to Curl_inet_ntop for DECC compiler squawk --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index f2ecfdc31..26b4fae0a 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -110,7 +110,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr; memcpy(&in, &(s->sin_addr.s_addr), sizeof(in)); - ip = Curl_inet_ntop(s->sin_family, &in, buf, buf_size); + ip = (char *) Curl_inet_ntop(s->sin_family, &in, buf, buf_size); } sclose(dummy); } -- cgit v1.2.1 From 16bbd13af7244cc0967d9f12327f63ffcaeac4bd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 13 Jul 2005 18:06:40 +0000 Subject: Diego Casorran patches to make (lib)curl build fine on Amiga again --- lib/if2ip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 26b4fae0a..c975ae200 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -34,7 +34,8 @@ #include "if2ip.h" #if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN32__) && \ - !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) + !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ + !defined(_AMIGASF) #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From 990e56fb13e1e538415a69c69754b21609a14ed6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 8 Jun 2006 06:12:30 +0000 Subject: Brian Dessent's fixes for cygwin builds --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index c975ae200..479428f80 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -33,7 +33,7 @@ #include "if2ip.h" -#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN32__) && \ +#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \ !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ !defined(_AMIGASF) -- cgit v1.2.1 From c012e2b408db31daf8b581255724d9fde9c37135 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 4 Aug 2006 18:53:47 +0000 Subject: Initial stab at making libcurl compile under Minix 3. --- lib/if2ip.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 479428f80..f2631a7ba 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -33,9 +33,13 @@ #include "if2ip.h" +/* + * This test can probably be simplified to #if defined(SIOCGIFADDR) and + * moved after the following includes. + */ #if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \ !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ - !defined(_AMIGASF) + !defined(_AMIGASF) && !defined(_MINIX) #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From eb26a581f95d208d3abcb1413bcd856a6e85a0e9 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 11 Aug 2006 18:11:42 +0000 Subject: Use __minix to detect Minix, which works on both ACK and GCC. --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index f2631a7ba..f3d31bc1d 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -39,7 +39,7 @@ */ #if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \ !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ - !defined(_AMIGASF) && !defined(_MINIX) + !defined(_AMIGASF) && !defined(__minix) #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From 839441e236764996425fe768e9497b1f914cea3e Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 16 Aug 2006 18:48:27 +0000 Subject: Minor portability fixes to get things running on UNICOS 9.0 on a Cray Y-MP --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index f3d31bc1d..fadf51474 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -114,7 +114,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) struct in_addr in; struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr; - memcpy(&in, &(s->sin_addr.s_addr), sizeof(in)); + memcpy(&in, &s->sin_addr, sizeof(in)); ip = (char *) Curl_inet_ntop(s->sin_family, &in, buf, buf_size); } sclose(dummy); -- cgit v1.2.1 From b2c378267beecae61b5fa608d2af3b3e4f0868d1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 25 Oct 2006 07:19:45 +0000 Subject: updated copyright year --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index fadf51474..b4a98c662 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From be8a5d0aef8eef4236d7cd6ce2cd7eabf74006f4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 28 Feb 2007 14:45:48 +0000 Subject: proper symbol definition check for all AmigaOS flavours --- lib/if2ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index b4a98c662..b21727156 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -39,7 +39,7 @@ */ #if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \ !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ - !defined(_AMIGASF) && !defined(__minix) + !defined(__AMIGA__) && !defined(__minix) #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From c38c33948067a3e2a170d337d940f7e27423ae07 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Apr 2007 20:09:19 +0000 Subject: Song Ma found a memory leak in the if2ip code if you pass in an interface name longer than the name field of the ifreq struct (typically 6 bytes), as then it wouldn't close the used dummy socket. --- lib/if2ip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index b21727156..02bc6b94a 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -98,8 +98,10 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) struct ifreq req; size_t len = strlen(interface); memset(&req, 0, sizeof(req)); - if(len >= sizeof(req.ifr_name)) + if(len >= sizeof(req.ifr_name)) { + sclose(dummy); return NULL; /* this can't be a fine interface name */ + } memcpy(req.ifr_name, interface, len+1); req.ifr_addr.sa_family = AF_INET; #ifdef IOCTL_3_ARGS -- cgit v1.2.1 From cbd1a77ec24e397d05f20c6de106625676343c9d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 7 Nov 2007 09:21:35 +0000 Subject: if () => if() while () => while() and some other minor re-indentings --- lib/if2ip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 02bc6b94a..518200cb8 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -91,7 +91,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) return NULL; dummy = socket(AF_INET, SOCK_STREAM, 0); - if (SYS_ERROR == dummy) { + if(SYS_ERROR == dummy) { return NULL; } else { @@ -105,9 +105,9 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) memcpy(req.ifr_name, interface, len+1); req.ifr_addr.sa_family = AF_INET; #ifdef IOCTL_3_ARGS - if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { + if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { #else - if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { + if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { #endif sclose(dummy); return NULL; -- cgit v1.2.1 From 1960eebc2d021ecf5ffc3f6d4e935d54aa592c72 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 22 Apr 2008 22:53:53 +0000 Subject: Added support for running on Symbian OS. --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 518200cb8..18696e9e7 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -39,7 +39,7 @@ */ #if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \ !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ - !defined(__AMIGA__) && !defined(__minix) + !defined(__AMIGA__) && !defined(__minix) && !defined(__SYMBIAN32__) #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From ee64d14733266ce533eeb3cbc86bd80212527b81 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 2 Jul 2008 18:34:00 +0000 Subject: Support Open Watcom C on Linux (as well as Windows). --- lib/if2ip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 18696e9e7..94a09c11e 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -39,7 +39,8 @@ */ #if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \ !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ - !defined(__AMIGA__) && !defined(__minix) && !defined(__SYMBIAN32__) + !defined(__AMIGA__) && !defined(__minix) && !defined(__SYMBIAN32__) && \ + !defined(__WATCOMC__) #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From fad3288d20fba6af71fa9bdfb851fe92c3aa2f04 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 9 Oct 2008 19:23:50 +0000 Subject: Fixed the --interface option to work with IPv6 connections on glibc systems supporting getifaddrs(). Also fixed a problem where an IPv6 address could be chosen instead of an IPv4 one for --interface when it involved a name lookup. --- lib/if2ip.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 94a09c11e..a54050040 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -42,6 +42,60 @@ !defined(__AMIGA__) && !defined(__minix) && !defined(__SYMBIAN32__) && \ !defined(__WATCOMC__) +#if defined(HAVE_GETIFADDRS) + +/* + * glibc provides getifaddrs() to provide a list of all interfaces and their + * addresses. + */ + +#include + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#include "inet_ntop.h" +#include "strequal.h" + +char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) +{ + struct ifaddrs *iface, *head; + char *ip=NULL; + + if (getifaddrs(&head) >= 0) { + for (iface=head; iface != NULL; iface=iface->ifa_next) { + if ((iface->ifa_addr->sa_family == af) && + curl_strequal(iface->ifa_name, interface)) { + void *addr; + char scope[12]=""; + if (af == AF_INET6) { + unsigned int scopeid; + addr = &((struct sockaddr_in6 *)iface->ifa_addr)->sin6_addr; + /* Include the scope of this interface as part of the address */ + scopeid = ((struct sockaddr_in6 *)iface->ifa_addr)->sin6_scope_id; + if (scopeid) + snprintf(scope, sizeof(scope), "%%%u", scopeid); + } else + addr = &((struct sockaddr_in *)iface->ifa_addr)->sin_addr; + ip = (char *) Curl_inet_ntop(af, addr, buf, buf_size); + Curl_strlcat(buf, scope, buf_size); + break; + } + } + freeifaddrs(head); + } + return ip; +} + +#else + #ifdef HAVE_SYS_SOCKET_H #include #endif @@ -83,12 +137,12 @@ #define SYS_ERROR -1 -char *Curl_if2ip(const char *interface, char *buf, int buf_size) +char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) { int dummy; char *ip=NULL; - if(!interface) + if(!interface || (af != AF_INET)) return NULL; dummy = socket(AF_INET, SOCK_STREAM, 0); @@ -124,11 +178,13 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size) } return ip; } +#endif /* -- end of if2ip() -- */ #else -char *Curl_if2ip(const char *interf, char *buf, int buf_size) +char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size) { + (void) af; (void) interf; (void) buf; (void) buf_size; -- cgit v1.2.1 From 8eb64ad6008e674fc2559892c3858f7af9edcd75 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Sun, 12 Oct 2008 15:17:15 +0000 Subject: Changed Curl_strlcat to strlcat, which is the one guaranteed to exist --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index a54050040..72fd0281f 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -85,7 +85,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) } else addr = &((struct sockaddr_in *)iface->ifa_addr)->sin_addr; ip = (char *) Curl_inet_ntop(af, addr, buf, buf_size); - Curl_strlcat(buf, scope, buf_size); + strlcat(buf, scope, buf_size); break; } } -- cgit v1.2.1 From d086fdaf9f16f0739b2a9eb4ca97aed8c7d26ade Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 25 Oct 2008 03:52:21 +0000 Subject: add missing header inclusions --- lib/if2ip.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 72fd0281f..9faa3b67a 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -64,6 +64,13 @@ #include "inet_ntop.h" #include "strequal.h" +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#include "memory.h" +/* The last #include file should be: */ +#include "memdebug.h" + char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) { struct ifaddrs *iface, *head; @@ -74,19 +81,20 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) if ((iface->ifa_addr->sa_family == af) && curl_strequal(iface->ifa_name, interface)) { void *addr; - char scope[12]=""; + char scope[12]=""; if (af == AF_INET6) { unsigned int scopeid; addr = &((struct sockaddr_in6 *)iface->ifa_addr)->sin6_addr; - /* Include the scope of this interface as part of the address */ + /* Include the scope of this interface as part of the address */ scopeid = ((struct sockaddr_in6 *)iface->ifa_addr)->sin6_scope_id; if (scopeid) - snprintf(scope, sizeof(scope), "%%%u", scopeid); - } else + snprintf(scope, sizeof(scope), "%%%u", scopeid); + } + else addr = &((struct sockaddr_in *)iface->ifa_addr)->sin_addr; ip = (char *) Curl_inet_ntop(af, addr, buf, buf_size); - strlcat(buf, scope, buf_size); - break; + strlcat(buf, scope, buf_size); + break; } } freeifaddrs(head); @@ -130,8 +138,11 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) #endif #include "inet_ntop.h" -#include "memory.h" +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +#include "memory.h" /* The last #include file should be: */ #include "memdebug.h" -- cgit v1.2.1 From 6354cbf9d6b1f16544c69d8a9d2b7816768da11b Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 7 Nov 2008 18:33:20 +0000 Subject: The getifaddrs() version of Curl_if2ip() crashed when used on a Linux system with a TEQL load-balancing device configured, which doesn't have an address. Thanks to Adam Sampson for spotting this (bug #2234923). --- lib/if2ip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 9faa3b67a..c591a957a 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -78,7 +78,8 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) if (getifaddrs(&head) >= 0) { for (iface=head; iface != NULL; iface=iface->ifa_next) { - if ((iface->ifa_addr->sa_family == af) && + if ((iface->ifa_addr != NULL) && + (iface->ifa_addr->sa_family == af) && curl_strequal(iface->ifa_name, interface)) { void *addr; char scope[12]=""; -- cgit v1.2.1 From 608fdce0a0541cbd73eb80e7db1b5e3df70d1bf5 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 17 Nov 2008 14:24:15 +0000 Subject: if2ip.c related preprocessor cleanup --- lib/if2ip.c | 111 ++++++++++++++++++------------------------------------------ 1 file changed, 33 insertions(+), 78 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index c591a957a..bf400df48 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -23,46 +23,43 @@ #include "setup.h" -#include -#include -#include - #ifdef HAVE_UNISTD_H -#include +# include #endif - -#include "if2ip.h" - -/* - * This test can probably be simplified to #if defined(SIOCGIFADDR) and - * moved after the following includes. - */ -#if !defined(WIN32) && !defined(__BEOS__) && !defined(__CYGWIN__) && \ - !defined(__riscos__) && !defined(__INTERIX) && !defined(NETWARE) && \ - !defined(__AMIGA__) && !defined(__minix) && !defined(__SYMBIAN32__) && \ - !defined(__WATCOMC__) - -#if defined(HAVE_GETIFADDRS) - -/* - * glibc provides getifaddrs() to provide a list of all interfaces and their - * addresses. - */ - -#include - #ifdef HAVE_SYS_SOCKET_H -#include +# include #endif #ifdef HAVE_NETINET_IN_H -#include +# include #endif #ifdef HAVE_ARPA_INET_H -#include +# include +#endif +#ifdef HAVE_NET_IF_H +# include +#endif +#ifdef HAVE_SYS_IOCTL_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_SYS_SOCKIO_H +# include +#endif +#ifdef HAVE_IFADDRS_H +# include +#endif +#ifdef HAVE_STROPTS_H +# include +#endif +#ifdef VMS +# include #endif #include "inet_ntop.h" #include "strequal.h" +#include "if2ip.h" #define _MPRINTF_REPLACE /* use our functions only */ #include @@ -71,6 +68,10 @@ /* The last #include file should be: */ #include "memdebug.h" +------------------------------------------------------------------ + +#if defined(HAVE_GETIFADDRS) + char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) { struct ifaddrs *iface, *head; @@ -103,49 +104,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) return ip; } -#else - -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif - -#ifdef HAVE_SYS_TIME_H -/* This must be before net/if.h for AIX 3.2 to enjoy life */ -#include -#endif -#ifdef HAVE_NET_IF_H -#include -#endif -#ifdef HAVE_SYS_IOCTL_H -#include -#endif - -#ifdef HAVE_NETDB_H -#include -#endif - -#ifdef HAVE_SYS_SOCKIO_H -#include -#endif - -#ifdef VMS -#include -#endif - -#include "inet_ntop.h" - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -#include "memory.h" -/* The last #include file should be: */ -#include "memdebug.h" +#elif defined(HAVE_IOCTL_SIOCGIFADDR) #define SYS_ERROR -1 @@ -171,11 +130,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) } memcpy(req.ifr_name, interface, len+1); req.ifr_addr.sa_family = AF_INET; -#ifdef IOCTL_3_ARGS if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { -#else - if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) { -#endif sclose(dummy); return NULL; } @@ -190,10 +145,9 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) } return ip; } -#endif -/* -- end of if2ip() -- */ #else + char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size) { (void) af; @@ -202,4 +156,5 @@ char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size) (void) buf_size; return NULL; } + #endif -- cgit v1.2.1 From 20d3e2b9675d4158625e8e413e5c09f65cb80cab Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 17 Nov 2008 14:26:22 +0000 Subject: fix comment --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index bf400df48..1c82373f1 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -68,7 +68,7 @@ /* The last #include file should be: */ #include "memdebug.h" ------------------------------------------------------------------- +/* ------------------------------------------------------------------ */ #if defined(HAVE_GETIFADDRS) -- cgit v1.2.1 From a15b6a6f86229de50f7622e23a6b19c040d3d4e1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 17 Nov 2008 19:08:35 +0000 Subject: the IP address we want/request/use from the interface is the 'local' address, the one on the box libcurl is running, not the 'remote' one. --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 1c82373f1..842cd9947 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -137,7 +137,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) else { struct in_addr in; - struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr; + struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_addr; memcpy(&in, &s->sin_addr, sizeof(in)); ip = (char *) Curl_inet_ntop(s->sin_family, &in, buf, buf_size); } -- cgit v1.2.1 From 7abdc4b21811e2d52f49fcf1380c48ccd46b3cc0 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 4 Dec 2008 06:24:00 +0000 Subject: Fixed the getifaddrs version of Curl_if2ip to work on systems without IPv6 support (e.g. Minix) --- lib/if2ip.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 842cd9947..74cd5266e 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -84,6 +84,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) curl_strequal(iface->ifa_name, interface)) { void *addr; char scope[12]=""; +#ifdef ENABLE_IPV6 if (af == AF_INET6) { unsigned int scopeid; addr = &((struct sockaddr_in6 *)iface->ifa_addr)->sin6_addr; @@ -93,6 +94,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) snprintf(scope, sizeof(scope), "%%%u", scopeid); } else +#endif addr = &((struct sockaddr_in *)iface->ifa_addr)->sin_addr; ip = (char *) Curl_inet_ntop(af, addr, buf, buf_size); strlcat(buf, scope, buf_size); -- cgit v1.2.1 From 1cc50d31f9962264fd78cdbe6a27dac10742dcd6 Mon Sep 17 00:00:00 2001 From: Gunter Knauf Date: Tue, 30 Dec 2008 08:05:38 +0000 Subject: changed HAVE_SIN6_SCOPE_ID define to HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID since just found that ares already uses this define. --- lib/if2ip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 74cd5266e..0e74042d2 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -86,10 +86,12 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) char scope[12]=""; #ifdef ENABLE_IPV6 if (af == AF_INET6) { - unsigned int scopeid; + unsigned int scopeid = 0; addr = &((struct sockaddr_in6 *)iface->ifa_addr)->sin6_addr; +#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID /* Include the scope of this interface as part of the address */ scopeid = ((struct sockaddr_in6 *)iface->ifa_addr)->sin6_scope_id; +#endif if (scopeid) snprintf(scope, sizeof(scope), "%%%u", scopeid); } -- cgit v1.2.1 From 6a378a28b494274c144e2a8e4a870c2707a6f601 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 11 Apr 2009 06:36:47 +0000 Subject: Use 'curl_socket_t' instead of 'int' for socket. Avoid unnecessary'if-else' nesting. --- lib/if2ip.c | 51 ++++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 0e74042d2..f43658902 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -110,43 +110,40 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) #elif defined(HAVE_IOCTL_SIOCGIFADDR) -#define SYS_ERROR -1 - char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) { - int dummy; - char *ip=NULL; + struct ifreq req; + struct in_addr in; + struct sockaddr_in *s; + curl_socket_t dummy; + size_t len; + char *ip; if(!interface || (af != AF_INET)) return NULL; + len = strlen(interface); + if(len >= sizeof(req.ifr_name)) + return NULL; + dummy = socket(AF_INET, SOCK_STREAM, 0); - if(SYS_ERROR == dummy) { + if(CURL_SOCKET_BAD == dummy) return NULL; - } - else { - struct ifreq req; - size_t len = strlen(interface); - memset(&req, 0, sizeof(req)); - if(len >= sizeof(req.ifr_name)) { - sclose(dummy); - return NULL; /* this can't be a fine interface name */ - } - memcpy(req.ifr_name, interface, len+1); - req.ifr_addr.sa_family = AF_INET; - if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) { - sclose(dummy); - return NULL; - } - else { - struct in_addr in; - struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_addr; - memcpy(&in, &s->sin_addr, sizeof(in)); - ip = (char *) Curl_inet_ntop(s->sin_family, &in, buf, buf_size); - } + memset(&req, 0, sizeof(req)); + memcpy(req.ifr_name, interface, len+1); + req.ifr_addr.sa_family = AF_INET; + + if(ioctl(dummy, SIOCGIFADDR, &req) < 0) { sclose(dummy); + return NULL; } + + s = (struct sockaddr_in *)&req.ifr_addr; + memcpy(&in, &s->sin_addr, sizeof(in)); + ip = (char *) Curl_inet_ntop(s->sin_family, &in, buf, buf_size); + + sclose(dummy); return ip; } -- cgit v1.2.1 From 33a3753c3f41d546ebf3350685eb7201d25783f4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 21 Apr 2009 11:46:16 +0000 Subject: libcurl's memory.h renamed to curl_memory.h --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index f43658902..f0159457c 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -64,7 +64,7 @@ #define _MPRINTF_REPLACE /* use our functions only */ #include -#include "memory.h" +#include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" -- cgit v1.2.1 From 3184a91ec86b2f35f16a8e11e2daa03fac8e91b6 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 30 Dec 2009 17:59:56 +0000 Subject: VMS specific preprocessor symbol checking adjustments --- lib/if2ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index f0159457c..b8ed4c81c 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -53,7 +53,7 @@ #ifdef HAVE_STROPTS_H # include #endif -#ifdef VMS +#ifdef __VMS # include #endif -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- lib/if2ip.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index b8ed4c81c..19504d1fd 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -18,7 +18,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From b903186fa0189ff241d756d25d07fdfe9885ae49 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 20 Apr 2011 15:17:42 +0200 Subject: source cleanup: unify look, style and indent levels By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed. --- lib/if2ip.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 19504d1fd..4924f7301 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -76,22 +76,22 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) struct ifaddrs *iface, *head; char *ip=NULL; - if (getifaddrs(&head) >= 0) { - for (iface=head; iface != NULL; iface=iface->ifa_next) { - if ((iface->ifa_addr != NULL) && - (iface->ifa_addr->sa_family == af) && - curl_strequal(iface->ifa_name, interface)) { + if(getifaddrs(&head) >= 0) { + for(iface=head; iface != NULL; iface=iface->ifa_next) { + if((iface->ifa_addr != NULL) && + (iface->ifa_addr->sa_family == af) && + curl_strequal(iface->ifa_name, interface)) { void *addr; char scope[12]=""; #ifdef ENABLE_IPV6 - if (af == AF_INET6) { + if(af == AF_INET6) { unsigned int scopeid = 0; addr = &((struct sockaddr_in6 *)iface->ifa_addr)->sin6_addr; #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID /* Include the scope of this interface as part of the address */ scopeid = ((struct sockaddr_in6 *)iface->ifa_addr)->sin6_scope_id; #endif - if (scopeid) + if(scopeid) snprintf(scope, sizeof(scope), "%%%u", scopeid); } else -- cgit v1.2.1 From 6e4835c795996ee92ac1aa78733f23a089f310a5 Mon Sep 17 00:00:00 2001 From: Jason Glasgow Date: Fri, 4 Nov 2011 16:48:05 -0400 Subject: CURLOPT_INTERFACE: avoid resolving interfaces names Do not try to resolve interfaces names via DNS by recognizing interface names in a few ways. If the interface option argument has a prefix of "if!" then treat the argument as only an interface. Similarly, if the interface argument is the name of an interface (even if it does not have an IP address assigned), treat it as an interface name. Finally, if the interface argument is prefixed by "host!" treat it as a hostname that must be resolved by /etc/hosts or DNS. These changes allow a client using the multi interfaces to avoid blocking on name resolution if the interface loses its IP address or disappears. --- lib/if2ip.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 4924f7301..0ae375b15 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -71,6 +71,24 @@ #if defined(HAVE_GETIFADDRS) +bool Curl_if_is_interface_name(const char *interface) +{ + bool result = FALSE; + + struct ifaddrs *iface, *head; + + if(getifaddrs(&head) >= 0) { + for(iface=head; iface != NULL; iface=iface->ifa_next) { + if(curl_strequal(iface->ifa_name, interface)) { + result = TRUE; + break; + } + } + freeifaddrs(head); + } + return result; +} + char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) { struct ifaddrs *iface, *head; @@ -109,6 +127,14 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) #elif defined(HAVE_IOCTL_SIOCGIFADDR) +bool Curl_if_is_interface_name(const char *interface) +{ + /* This is here just to support the old interfaces */ + char buf[256]; + + return (Curl_if2ip(AF_INET, interface, buf, sizeof(buf)) != NULL); +} + char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) { struct ifreq req; @@ -148,6 +174,11 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) #else +bool Curl_if_is_interface_name(const char *interface) +{ + return FALSE; +} + char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size) { (void) af; -- cgit v1.2.1 From 07efe110cc7dce18e6ef4ff73b1acbd30842471c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 13 Dec 2011 15:47:26 +0100 Subject: if2ip.c: fix compiler warning 'enumerated type is mixed with another type' --- lib/if2ip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 0ae375b15..864fcb3fa 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -92,7 +92,7 @@ bool Curl_if_is_interface_name(const char *interface) char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) { struct ifaddrs *iface, *head; - char *ip=NULL; + char *ip = NULL; if(getifaddrs(&head) >= 0) { for(iface=head; iface != NULL; iface=iface->ifa_next) { @@ -132,7 +132,9 @@ bool Curl_if_is_interface_name(const char *interface) /* This is here just to support the old interfaces */ char buf[256]; - return (Curl_if2ip(AF_INET, interface, buf, sizeof(buf)) != NULL); + char *ip = Curl_if2ip(AF_INET, interface, buf, sizeof(buf)); + + return (ip != NULL) ? TRUE : FALSE; } char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) -- cgit v1.2.1 From 66c50762528390677f6546b63707d24537368cb5 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 13 Dec 2011 16:08:42 +0100 Subject: if2ip.c: fix compiler warning 'unused parameter' --- lib/if2ip.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index 864fcb3fa..c253ed5d1 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -178,6 +178,8 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) bool Curl_if_is_interface_name(const char *interface) { + (void) interface; + return FALSE; } -- cgit v1.2.1 From 4c4e8ba1f060fdba2822da5ad498c7876cedd18b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 13 Dec 2011 18:37:33 +0100 Subject: if2ip.[ch]: fix compilation with MinGW Avoid 'interface' literal that some MinGW versions define as a macro --- lib/if2ip.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/if2ip.c') diff --git a/lib/if2ip.c b/lib/if2ip.c index c253ed5d1..055ee7aa0 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -71,7 +71,7 @@ #if defined(HAVE_GETIFADDRS) -bool Curl_if_is_interface_name(const char *interface) +bool Curl_if_is_interface_name(const char *interf) { bool result = FALSE; @@ -79,7 +79,7 @@ bool Curl_if_is_interface_name(const char *interface) if(getifaddrs(&head) >= 0) { for(iface=head; iface != NULL; iface=iface->ifa_next) { - if(curl_strequal(iface->ifa_name, interface)) { + if(curl_strequal(iface->ifa_name, interf)) { result = TRUE; break; } @@ -89,7 +89,7 @@ bool Curl_if_is_interface_name(const char *interface) return result; } -char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) +char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size) { struct ifaddrs *iface, *head; char *ip = NULL; @@ -98,7 +98,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) for(iface=head; iface != NULL; iface=iface->ifa_next) { if((iface->ifa_addr != NULL) && (iface->ifa_addr->sa_family == af) && - curl_strequal(iface->ifa_name, interface)) { + curl_strequal(iface->ifa_name, interf)) { void *addr; char scope[12]=""; #ifdef ENABLE_IPV6 @@ -127,17 +127,17 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) #elif defined(HAVE_IOCTL_SIOCGIFADDR) -bool Curl_if_is_interface_name(const char *interface) +bool Curl_if_is_interface_name(const char *interf) { /* This is here just to support the old interfaces */ char buf[256]; - char *ip = Curl_if2ip(AF_INET, interface, buf, sizeof(buf)); + char *ip = Curl_if2ip(AF_INET, interf, buf, sizeof(buf)); return (ip != NULL) ? TRUE : FALSE; } -char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) +char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size) { struct ifreq req; struct in_addr in; @@ -146,10 +146,10 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) size_t len; char *ip; - if(!interface || (af != AF_INET)) + if(!interf || (af != AF_INET)) return NULL; - len = strlen(interface); + len = strlen(interf); if(len >= sizeof(req.ifr_name)) return NULL; @@ -158,7 +158,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) return NULL; memset(&req, 0, sizeof(req)); - memcpy(req.ifr_name, interface, len+1); + memcpy(req.ifr_name, interf, len+1); req.ifr_addr.sa_family = AF_INET; if(ioctl(dummy, SIOCGIFADDR, &req) < 0) { @@ -176,9 +176,9 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) #else -bool Curl_if_is_interface_name(const char *interface) +bool Curl_if_is_interface_name(const char *interf) { - (void) interface; + (void) interf; return FALSE; } -- cgit v1.2.1