From: Zoran V. <vas...@us...> - 2005-06-10 10:12:50
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8702 Modified Files: binder.c Log Message: First pass: reformatted and untabified. Index: binder.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/binder.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** binder.c 24 Feb 2005 17:24:52 -0000 1.3 --- binder.c 10 Jun 2005 10:12:36 -0000 1.4 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://aolserver.com/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 32,36 **** * binder.c -- * ! *Support for pre-bound privileged ports. */ --- 32,36 ---- * binder.c -- * ! * Support for pre-bound privileged ports. */ *************** *** 43,47 **** --- 43,51 ---- */ + + #ifndef _WIN32 static void PreBind(char *line); + #endif + static Tcl_HashTable preboundTcp; static Tcl_HashTable preboundUdp; *************** *** 51,55 **** - /* *---------------------------------------------------------------------- --- 55,58 ---- *************** *** 57,68 **** * Ns_SockListenEx -- * ! * Create a new socket bound to the specified port and listening ! * for new connections. * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 60,71 ---- * Ns_SockListenEx -- * ! * Create a new socket bound to the specified port and listening ! * for new connections. * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 77,101 **** if (Ns_GetSockAddr(&sa, address, port) != NS_OK) { ! return -1; } Ns_MutexLock(&lock); hPtr = Tcl_FindHashEntry(&preboundTcp, (char *) &sa); if (hPtr != NULL) { ! sock = (int) Tcl_GetHashValue(hPtr); ! Tcl_DeleteHashEntry(hPtr); } Ns_MutexUnlock(&lock); if (hPtr == NULL) { ! sock = Ns_SockBind(&sa); } if (sock != -1 && listen(sock, backlog) != 0) { ! err = errno; ! close(sock); ! errno = err; ! sock = -1; } return sock; } /* *---------------------------------------------------------------------- --- 80,106 ---- if (Ns_GetSockAddr(&sa, address, port) != NS_OK) { ! return -1; } Ns_MutexLock(&lock); hPtr = Tcl_FindHashEntry(&preboundTcp, (char *) &sa); if (hPtr != NULL) { ! sock = (int) Tcl_GetHashValue(hPtr); ! Tcl_DeleteHashEntry(hPtr); } Ns_MutexUnlock(&lock); if (hPtr == NULL) { ! sock = Ns_SockBind(&sa); } if (sock != -1 && listen(sock, backlog) != 0) { ! err = errno; ! close(sock); ! errno = err; ! sock = -1; } + return sock; } + /* *---------------------------------------------------------------------- *************** *** 103,113 **** * Ns_SockBindUdp -- * ! * Create a UDP socket and bind it to the passed-in address. * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 108,118 ---- * Ns_SockBindUdp -- * ! * Create a UDP socket and bind it to the passed-in address. * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 119,133 **** int sock, err, n = 1; ! if((sock = socket(AF_INET,SOCK_DGRAM,0)) < 0 || ! setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) < 0 || ! bind(sock,(struct sockaddr *)saPtr,sizeof(struct sockaddr_in)) < 0) { ! err = errno; ! close(sock); ! Ns_SetSockErrno(err); ! sock = -1; } return sock; } /* *---------------------------------------------------------------------- --- 124,142 ---- int sock, err, n = 1; ! sock = socket(AF_INET,SOCK_DGRAM, 0); ! ! if (sock < 0 ! || setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) < 0 ! || bind(sock,(struct sockaddr *)saPtr, sizeof(struct sockaddr_in)) < 0) { ! err = errno; ! close(sock); ! Ns_SetSockErrno(err); ! sock = -1; } + return sock; } + /* *---------------------------------------------------------------------- *************** *** 135,145 **** * Ns_SockRaw -- * ! * Helper routine for creating a raw socket * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 144,154 ---- * Ns_SockRaw -- * ! * Helper routine for creating a raw socket * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 151,163 **** int sock, err; ! if((sock = socket(AF_INET,SOCK_RAW,proto)) < 0) { ! err = errno; ! close(sock); ! Ns_SetSockErrno(err); ! sock = -1; } return sock; } /* *---------------------------------------------------------------------- --- 160,176 ---- int sock, err; ! sock = socket(AF_INET,SOCK_RAW, proto); ! ! if (sock < 0) { ! err = errno; ! close(sock); ! Ns_SetSockErrno(err); ! sock = -1; } + return sock; } + /* *---------------------------------------------------------------------- *************** *** 165,176 **** * Ns_SockListenUdp -- * ! * Create a new UDP socket bound to the specified port and listening ! * for new connections. * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 178,189 ---- * Ns_SockListenUdp -- * ! * Create a new UDP socket bound to the specified port and ! * listening for new connections. * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 185,203 **** if (Ns_GetSockAddr(&sa, address, port) != NS_OK) { ! return -1; } Ns_MutexLock(&lock); hPtr = Tcl_FindHashEntry(&preboundUdp, (char *) &sa); if (hPtr != NULL) { ! sock = (int) Tcl_GetHashValue(hPtr); ! Tcl_DeleteHashEntry(hPtr); } Ns_MutexUnlock(&lock); if (hPtr == NULL) { ! sock = Ns_SockBindUdp(&sa); } return sock; } /* *---------------------------------------------------------------------- --- 198,218 ---- if (Ns_GetSockAddr(&sa, address, port) != NS_OK) { ! return -1; } Ns_MutexLock(&lock); hPtr = Tcl_FindHashEntry(&preboundUdp, (char *) &sa); if (hPtr != NULL) { ! sock = (int) Tcl_GetHashValue(hPtr); ! Tcl_DeleteHashEntry(hPtr); } Ns_MutexUnlock(&lock); if (hPtr == NULL) { ! sock = Ns_SockBindUdp(&sa); } + return sock; } + /* *---------------------------------------------------------------------- *************** *** 205,215 **** * Ns_SockListenRaw -- * ! * Create a new RAW socket * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 220,230 ---- * Ns_SockListenRaw -- * ! * Create a new RAW socket * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 226,233 **** hPtr = Tcl_FirstHashEntry(&preboundRaw, &search); while (hPtr != NULL) { ! if(proto == (int)Tcl_GetHashValue(hPtr)) { ! sock = (int)Tcl_GetHashKey(&preboundRaw, hPtr); ! Tcl_DeleteHashEntry(hPtr); ! break; } hPtr = Tcl_NextHashEntry(&search); --- 241,248 ---- hPtr = Tcl_FirstHashEntry(&preboundRaw, &search); while (hPtr != NULL) { ! if (proto == (int)Tcl_GetHashValue(hPtr)) { ! sock = (int)Tcl_GetHashKey(&preboundRaw, hPtr); ! Tcl_DeleteHashEntry(hPtr); ! break; } hPtr = Tcl_NextHashEntry(&search); *************** *** 235,255 **** Ns_MutexUnlock(&lock); if (hPtr == NULL) { ! sock = Ns_SockRaw(proto); } return sock; } /* *---------------------------------------------------------------------- * ! * ListenUnix -- * ! * Helper routine for creating a listening UNIX domain socket. * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 250,272 ---- Ns_MutexUnlock(&lock); if (hPtr == NULL) { ! sock = Ns_SockRaw(proto); } + return sock; } + /* *---------------------------------------------------------------------- * ! * Ns_SockListenUnix -- * ! * Helper routine for creating a listening UNIX domain socket. * * Results: ! * Socket descriptor or -1 on error. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 262,276 **** struct sockaddr_un addr; ! memset(&addr,0,sizeof(addr)); addr.sun_family = AF_UNIX; ! strncpy(addr.sun_path,path,sizeof(addr.sun_path)-1); unlink(path); ! if((sock = socket(AF_UNIX,SOCK_STREAM,0)) < 0 || ! bind(sock,(struct sockaddr*)&addr,sizeof(addr)) < 0) { ! err = errno; ! close(sock); ! Ns_SetSockErrno(err); ! sock = -1; } return sock; } --- 279,296 ---- struct sockaddr_un addr; ! memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; ! strncpy(addr.sun_path,path, sizeof(addr.sun_path) - 1); unlink(path); ! ! sock = socket(AF_UNIX,SOCK_STREAM, 0); ! if (sock < 0 ! || bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { ! err = errno; ! close(sock); ! Ns_SetSockErrno(err); ! sock = -1; } + return sock; } *************** *** 282,292 **** * NsInitBinder -- * ! * Initialize the pre-bind table. * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 302,312 ---- * NsInitBinder -- * ! * Initialize the pre-bind table. * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 302,305 **** --- 322,327 ---- } + #ifndef _WIN32 + /* *************** *** 308,318 **** * NsPreBind -- * ! * Pre-bind any requested ports, called from Ns_Main at startup. * * Results: ! * None. * * Side effects: ! * May pre-bind to one or more ports. * *---------------------------------------------------------------------- --- 330,340 ---- * NsPreBind -- * ! * Pre-bind any requested ports, called from Ns_Main at startup. * * Results: ! * None. * * Side effects: ! * May pre-bind to one or more ports. * *---------------------------------------------------------------------- *************** *** 326,336 **** if (args != NULL) { ! PreBind(args); } if (file != NULL && (fp = fopen(file, "r")) != NULL) { ! while (fgets(line, sizeof(line), fp) != NULL) { ! PreBind(line); ! } ! fclose(fp); } } --- 348,358 ---- if (args != NULL) { ! PreBind(args); } if (file != NULL && (fp = fopen(file, "r")) != NULL) { ! while (fgets(line, sizeof(line), fp) != NULL) { ! PreBind(line); ! } ! fclose(fp); } } *************** *** 342,352 **** * NsClosePreBound -- * ! * Close any remaining pre-bound sockets. * * Results: ! * None. * * Side effects: ! * Pre-bound sockets closed. * *---------------------------------------------------------------------- --- 364,374 ---- * NsClosePreBound -- * ! * Close any remaining pre-bound sockets. * * Results: ! * None. * * Side effects: ! * Pre-bound sockets closed. * *---------------------------------------------------------------------- *************** *** 361,410 **** int port, sock; struct sockaddr_in *saPtr; ! Ns_MutexLock(&lock); hPtr = Tcl_FirstHashEntry(&preboundTcp, &search); while (hPtr != NULL) { ! saPtr = (struct sockaddr_in *) Tcl_GetHashKey(&preboundTcp, hPtr); ! addr = ns_inet_ntoa(saPtr->sin_addr); ! port = htons(saPtr->sin_port); ! sock = (int)Tcl_GetHashValue(hPtr); ! Ns_Log(Warning, "prebind: closed unused TCP: %s:%d = %d", addr, port, sock); ! close(sock); ! hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&preboundTcp); Tcl_InitHashTable(&preboundTcp, sizeof(struct sockaddr_in)/sizeof(int)); hPtr = Tcl_FirstHashEntry(&preboundUdp, &search); while (hPtr != NULL) { ! saPtr = (struct sockaddr_in *) Tcl_GetHashKey(&preboundUdp, hPtr); ! addr = ns_inet_ntoa(saPtr->sin_addr); ! port = htons(saPtr->sin_port); ! sock = (int)Tcl_GetHashValue(hPtr); ! Ns_Log(Warning, "prebind: closed unused UDP: %s:%d = %d", addr, port, sock); ! close(sock); ! hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&preboundUdp); Tcl_InitHashTable(&preboundUdp, sizeof(struct sockaddr_in)/sizeof(int)); hPtr = Tcl_FirstHashEntry(&preboundRaw, &search); while (hPtr != NULL) { ! sock = (int)Tcl_GetHashKey(&preboundRaw, hPtr); ! port = (int)Tcl_GetHashValue(hPtr); ! Ns_Log(Warning, "prebind: closed unused RAW: %d = %d", port, sock); ! close(sock); ! hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&preboundRaw); Tcl_InitHashTable(&preboundRaw, TCL_ONE_WORD_KEYS); hPtr = Tcl_FirstHashEntry(&preboundUnix, &search); while (hPtr != NULL) { ! addr = (char *) Tcl_GetHashKey(&preboundUnix, hPtr); ! sock = (int)Tcl_GetHashValue(hPtr); ! Ns_Log(Warning, "prebind: closed unused Unix: %s = %d", addr, sock); ! close(sock); ! hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&preboundUnix); Tcl_InitHashTable(&preboundUnix, TCL_STRING_KEYS); Ns_MutexUnlock(&lock); } --- 383,437 ---- int port, sock; struct sockaddr_in *saPtr; ! Ns_MutexLock(&lock); + hPtr = Tcl_FirstHashEntry(&preboundTcp, &search); while (hPtr != NULL) { ! saPtr = (struct sockaddr_in *) Tcl_GetHashKey(&preboundTcp, hPtr); ! addr = ns_inet_ntoa(saPtr->sin_addr); ! port = htons(saPtr->sin_port); ! sock = (int)Tcl_GetHashValue(hPtr); ! Ns_Log(Warning, "prebind: closed unused TCP: %s:%d = %d", addr, port, sock); ! close(sock); ! hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&preboundTcp); Tcl_InitHashTable(&preboundTcp, sizeof(struct sockaddr_in)/sizeof(int)); + hPtr = Tcl_FirstHashEntry(&preboundUdp, &search); while (hPtr != NULL) { ! saPtr = (struct sockaddr_in *) Tcl_GetHashKey(&preboundUdp, hPtr); ! addr = ns_inet_ntoa(saPtr->sin_addr); ! port = htons(saPtr->sin_port); ! sock = (int)Tcl_GetHashValue(hPtr); ! Ns_Log(Warning, "prebind: closed unused UDP: %s:%d = %d", addr, port, sock); ! close(sock); ! hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&preboundUdp); Tcl_InitHashTable(&preboundUdp, sizeof(struct sockaddr_in)/sizeof(int)); + hPtr = Tcl_FirstHashEntry(&preboundRaw, &search); while (hPtr != NULL) { ! sock = (int)Tcl_GetHashKey(&preboundRaw, hPtr); ! port = (int)Tcl_GetHashValue(hPtr); ! Ns_Log(Warning, "prebind: closed unused RAW: %d = %d", port, sock); ! close(sock); ! hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&preboundRaw); Tcl_InitHashTable(&preboundRaw, TCL_ONE_WORD_KEYS); + hPtr = Tcl_FirstHashEntry(&preboundUnix, &search); while (hPtr != NULL) { ! addr = (char *) Tcl_GetHashKey(&preboundUnix, hPtr); ! sock = (int)Tcl_GetHashValue(hPtr); ! Ns_Log(Warning, "prebind: closed unused Unix: %s = %d", addr, sock); ! close(sock); ! hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&preboundUnix); Tcl_InitHashTable(&preboundUnix, TCL_STRING_KEYS); + Ns_MutexUnlock(&lock); } *************** *** 416,430 **** * PreBind -- * ! * Pre-bind to one or more ports in a comma-separated list. ! * addr:port[/protocol] ! * port[/protocol] ! * 0/icmp[/count] ! * /path * Results: ! * None. * * Side effects: ! * Sockets are left in bound state for later listen ! * in Ns_SockListen. * *---------------------------------------------------------------------- --- 443,459 ---- * PreBind -- * ! * Pre-bind to one or more ports in a comma-separated list: ! * ! * addr:port[/protocol] ! * port[/protocol] ! * 0/icmp[/count] ! * /path ! * * Results: ! * None. * * Side effects: ! * Sockets are left in bound state for later listen ! * in Ns_SockListen. * *---------------------------------------------------------------------- *************** *** 439,539 **** char *next, *str, *addr, *proto; ! for(;line != NULL;line = next) { ! if((next = strchr(line, ','))) { ! *next++ = '\0'; ! } ! proto = "tcp"; ! addr = "0.0.0.0"; ! /* Parse port */ ! if((str = strchr(line, ':'))) { ! *str++ = '\0'; ! port = atoi(str); ! addr = line; ! line = str; ! } else { ! port = atoi(line); ! } ! /* Parse protocol */ ! if(*line != '/' && (str = strchr(line,'/'))) { ! *str++ = '\0'; ! proto = str; ! } ! ! if(!strcmp(proto,"tcp") && port > 0) { ! if(Ns_GetSockAddr(&sa, addr, port) != NS_OK) { ! Ns_Log(Error, "prebind: tcp: invalid address: %s:%d",addr,port); ! continue; ! } ! hPtr = Tcl_CreateHashEntry(&preboundTcp, (char *) &sa, &new); ! if(!new) { ! Ns_Log(Error, "prebind: tcp: duplicate entry: %s:%d",addr,port); ! continue; ! } ! if((sock = Ns_SockBind(&sa)) == -1) { ! Ns_Log(Error, "prebind: tcp: %s:%d: %s",addr,port,strerror(errno)); ! Tcl_DeleteHashEntry(hPtr); ! continue; ! } ! Tcl_SetHashValue(hPtr, sock); ! Ns_Log(Notice, "prebind: tcp: %s:%d = %d", addr, port, sock); ! } ! if(!strcmp(proto,"udp") && port > 0) { ! if(Ns_GetSockAddr(&sa, addr, port) != NS_OK) { ! Ns_Log(Error, "prebind: udp: invalid address: %s:%d",addr,port); ! continue; ! } ! hPtr = Tcl_CreateHashEntry(&preboundUdp, (char *) &sa, &new); ! if(!new) { ! Ns_Log(Error, "prebind: udp: duplicate entry: %s:%d",addr,port); ! continue; ! } ! if((sock = Ns_SockBindUdp(&sa)) == -1) { ! Ns_Log(Error, "prebind: udp: %s:%d: %s",addr,port,strerror(errno)); ! Tcl_DeleteHashEntry(hPtr); ! continue; ! } ! Tcl_SetHashValue(hPtr, sock); ! Ns_Log(Notice, "prebind: udp: %s:%d = %d", addr, port, sock); ! } ! if(!strncmp(proto,"icmp",4)) { ! int count = 1; ! /* Parse count */ ! if((str = strchr(str,'/'))) { ! *(str++) = '\0'; ! count = atoi(str); ! } ! while(count--) { ! if((sock = Ns_SockRaw(IPPROTO_ICMP)) == -1) { ! Ns_Log(Error, "prebind: icmp: %s",strerror(errno)); ! continue; ! } ! hPtr = Tcl_CreateHashEntry(&preboundRaw, (char *) sock, &new); ! if(!new) { ! Ns_Log(Error, "prebind: icmp: duplicate entry"); ! close(sock); ! continue; ! } ! Tcl_SetHashValue(hPtr, IPPROTO_ICMP); ! Ns_Log(Notice, "prebind: icmp: %d", sock); ! } ! } ! if(*line == '/') { ! hPtr = Tcl_CreateHashEntry(&preboundUnix, (char *) line, &new); ! if(!new) { ! Ns_Log(Error, "prebind: unix: duplicate entry: %s",line); ! continue; ! } ! if((sock = Ns_SockListenUnix(line)) == -1) { ! Ns_Log(Error, "prebind: unix: %s: %s",proto,strerror(errno)); ! Tcl_DeleteHashEntry(hPtr); ! continue; ! } ! Tcl_SetHashValue(hPtr, sock); ! Ns_Log(Notice, "prebind: unix: %s = %d", line, sock); ! } } } --- 468,582 ---- char *next, *str, *addr, *proto; ! for (;line != NULL; line = next) { ! next = strchr(line, ','); ! if (next) { ! *next++ = '\0'; ! } ! proto = "tcp"; ! addr = "0.0.0.0"; ! /* Parse port */ ! str = strchr(line, ':'); ! if (str) { ! *str++ = '\0'; ! port = atoi(str); ! addr = line; ! line = str; ! } else { ! port = atoi(line); ! } ! /* Parse protocol */ ! if (*line != '/' && (str = strchr(line,'/'))) { ! *str++ = '\0'; ! proto = str; ! } ! ! if (!strcmp(proto,"tcp") && port > 0) { ! if (Ns_GetSockAddr(&sa, addr, port) != NS_OK) { ! Ns_Log(Error, "prebind: tcp: invalid address: %s:%d", ! addr, port); ! continue; ! } ! hPtr = Tcl_CreateHashEntry(&preboundTcp, (char *) &sa, &new); ! if (!new) { ! Ns_Log(Error, "prebind: tcp: duplicate entry: %s:%d", ! addr, port); ! continue; ! } ! sock = Ns_SockBind(&sa); ! if (sock == -1) { ! Ns_Log(Error, "prebind: tcp: %s:%d: %s", addr, port, ! strerror(errno)); ! Tcl_DeleteHashEntry(hPtr); ! continue; ! } ! Tcl_SetHashValue(hPtr, sock); ! Ns_Log(Notice, "prebind: tcp: %s:%d = %d", addr, port, sock); ! } ! if (!strcmp(proto,"udp") && port > 0) { ! if (Ns_GetSockAddr(&sa, addr, port) != NS_OK) { ! Ns_Log(Error, "prebind: udp: invalid address: %s:%d", ! addr, port); ! continue; ! } ! hPtr = Tcl_CreateHashEntry(&preboundUdp, (char *) &sa, &new); ! if (!new) { ! Ns_Log(Error, "prebind: udp: duplicate entry: %s:%d", ! addr, port); ! continue; ! } ! sock = Ns_SockBindUdp(&sa); ! if (sock == -1) { ! Ns_Log(Error, "prebind: udp: %s:%d: %s", addr, port, ! strerror(errno)); ! Tcl_DeleteHashEntry(hPtr); ! continue; ! } ! Tcl_SetHashValue(hPtr, sock); ! Ns_Log(Notice, "prebind: udp: %s:%d = %d", addr, port, sock); ! } ! if (!strncmp(proto,"icmp",4)) { ! int count = 1; ! /* Parse count */ ! str = strchr(str,'/'); ! if (str) { ! *(str++) = '\0'; ! count = atoi(str); ! } ! while(count--) { ! sock = Ns_SockRaw(IPPROTO_ICMP); ! if (sock == -1) { ! Ns_Log(Error, "prebind: icmp: %s",strerror(errno)); ! continue; ! } ! hPtr = Tcl_CreateHashEntry(&preboundRaw, (char *) sock, &new); ! if(!new) { ! Ns_Log(Error, "prebind: icmp: duplicate entry"); ! close(sock); ! continue; ! } ! Tcl_SetHashValue(hPtr, IPPROTO_ICMP); ! Ns_Log(Notice, "prebind: icmp: %d", sock); ! } ! } ! if (*line == '/') { ! hPtr = Tcl_CreateHashEntry(&preboundUnix, (char *) line, &new); ! if (!new) { ! Ns_Log(Error, "prebind: unix: duplicate entry: %s",line); ! continue; ! } ! sock = Ns_SockListenUnix(line); ! if (sock == -1) { ! Ns_Log(Error, "prebind: unix: %s: %s", proto, strerror(errno)); ! Tcl_DeleteHashEntry(hPtr); ! continue; ! } ! Tcl_SetHashValue(hPtr, sock); ! Ns_Log(Notice, "prebind: unix: %s = %d", line, sock); ! } } } + #endif /* _WIN32 */ |