diff -ruN noip-2.0.7.orig/Makefile noip-2.0.7/Makefile --- noip-2.0.7.orig/Makefile Thu Jan 16 16:33:22 2003 +++ noip-2.0.7/Makefile Sun Mar 2 13:58:48 2003 @@ -1,13 +1,13 @@ TGT=noip2 CC=gcc -PREFIX=/usr/local +PREFIX=@FINKPREFIX@ CONFDIR=${PREFIX}/etc BINDIR=${PREFIX}/bin # these defines are for linux and BSD LIBS= -ARCH=linux +ARCH=DARWIN # for solaris, uncomment the next two lines # LIBS=-lsocket -lnsl @@ -27,4 +27,3 @@ clean: rm -f *o - rm -f ${TGT} diff -ruN noip-2.0.7.orig/noip2.c noip-2.0.7/noip2.c --- noip-2.0.7.orig/noip2.c Thu Feb 27 10:49:40 2003 +++ noip-2.0.7/noip2.c Mon Mar 3 23:06:33 2003 @@ -85,6 +85,7 @@ #include #include #include +#include #include #include @@ -95,15 +96,20 @@ #endif #endif -#ifdef sun +#ifndef SIOCGIFADDR #include -#endif +#endif // sun & Darwin + +#if defined(__APPLE__) && defined(__GNUC__) + #include +#endif // Darwin -#define DEBUG +#define DEBUG #define ENCRYPT 1 #define MAX(x,y) (((x)>(y))?(x):(y)) +#define MAX_IF 8 #define READ_TIMEOUT 90 #define WRITE_TIMEOUT 60 @@ -116,7 +122,7 @@ #define VERSION "2.0.7" #define NOIP_NAME "dynupdate.no-ip.com" -#define USER_AGENT "User-Agent: Linux DUC "VERSION +#define USER_AGENT "User-Agent: Darwin DUC "VERSION #define SETTING_SCRIPT "settings.php?" #define USTRNG "username=" #define PWDSTRNG "&pass=" @@ -143,11 +149,13 @@ #define ARGK 128 #define ARGi 256 -#define NOGROUP "@@NO_GROUP@@" +#ifndef NOGROUP + #define NOGROUP "@@NO_GROUP@@" +#endif #define HOST 1 #define GROUP 2 #ifndef PREFIX - #define PREFIX "/usr/local" + #define PREFIX "@FINKPREFIX@" #endif #define CONFIG_FILEPATH PREFIX"/etc" #define CONFIG_FILENAME PREFIX"/etc/no-ip2.conf" @@ -220,7 +228,7 @@ #define CMSG21 "Please select the Internet interface from this list.\n" #define CMSG22 "By typing the number associated with it." #define CMSG23 "Too many network devices. Limit is %d" -#define CMSG24 "\nAuto configuration for Linux client of no-ip.com.\n" +#define CMSG24 "\nAuto configuration for Darwin client of no-ip.com.\n" #define CMSG25 "Can't create config file (%s)" #define CMSG25a "Re-run noip, adding '-c configfilename' as a parameter." #define CMSG26 "Can't rename config file (%s)" @@ -410,7 +418,7 @@ fprintf(stderr, "[ -d][ -D pid]"); #endif fprintf(stderr, "[ -i addr][ -S][ -M][ -h]"); - fprintf(stderr, "\n\nVersion Linux-%s\n", VERSION); + fprintf(stderr, "\n\nVersion Darwin-%s\n", VERSION); fprintf(stderr, "Options: -C create configuration data\n"); fprintf(stderr, " -F force NAT off\n"); fprintf(stderr, " -Y select all hosts/groups\n"); @@ -1570,7 +1578,7 @@ assert(g != NULL); gn = NULL; if (!*gnm) - gnm = NOGROUP; + gnm = (char *) NOGROUP; while (g) { if (strcmp(g->grp, gnm) == 0) // group name match? break; @@ -1800,13 +1808,27 @@ ///////////////////////////////////////////////////////////////////////////// int get_all_device_names(unsigned char *devs) { + int devnum=0; + unsigned char *p, *tmpp, *q, *dq; + +#if defined(__APPLE__) && defined(__GNUC__) + struct ifaddrs *foo, *iter; + + if( getifaddrs(&foo) < 0 ) { + perror("getifaddrs"); + exit(1); + } - int fd, i, devnum=0; - int num_ifreq; - unsigned char *p, *q, *dq; - struct ifreq *pIfr; - struct ifconf Ifc; - static struct ifreq IfcBuf[MAX_NET_DEVS]; + dq = devs; // add new name into list + for( iter = foo; iter != NULL; iter = iter->ifa_next ) { + q = dq; // add new name into list + tmpp = iter->ifa_name; +#else + int fd, i; + int num_ifreq; + struct ifreq *pIfr; + struct ifconf Ifc; + static struct ifreq IfcBuf[MAX_NET_DEVS]; Ifc.ifc_len = sizeof(IfcBuf); Ifc.ifc_buf = (char *) IfcBuf; @@ -1823,11 +1845,28 @@ dq = devs; // add new name into list for (pIfr=Ifc.ifc_req,i=0; iifr_name; - if (strcmp("lo", p) == 0) + tmpp = pIfr->ifr_name; +#endif // Darwin + /*** strip devices with no name ***/ + if (strlen(tmpp) <= 2 || tmpp == NULL) { + continue; + } + /*** strip localloop device ***/ + if (strncmp("lo", tmpp, 2) == 0) { continue; - if (strchr(p, ':') != NULL) +#if defined(__APPLE__) && defined(__GNUC__) + /*** strip extra Darwin devices ***/ + } else if (strncmp("gif", tmpp, 3) == 0) { + continue; + } else if (strncmp("stf", tmpp, 3) == 0) { + continue; +#endif // Darwin + } + /*** strip non device lines ***/ + if (strchr(tmpp, ':') != NULL) { continue; + } + p = tmpp; devnum++; while (*p) *q++ = *p++; @@ -1838,6 +1877,9 @@ } dq += LINELEN; } +#if defined(__APPLE__) && defined(__GNUC__) + freeifaddrs(foo); +#endif return devnum; } ///////////////////////////////////////////////////////////////////////////// @@ -1946,7 +1988,7 @@ close(socket_fd); groups = (struct GROUPS *)Malloc(sizeof(struct GROUPS)); - groups->grp = NOGROUP; + groups->grp = (char *) NOGROUP; groups->count = 0; groups->ncount = 0; groups->glink = NULL;