yp_ping.c (26135) | yp_ping.c (30252) |
---|---|
1/* 2 * Copyright (c) 1996, 1997 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 1996, 1997 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * |
32 * $Id: yp_ping.c,v 1.2 1997/05/25 18:54:11 wpaul Exp wpaul $ | 32 * $Id: yp_ping.c,v 1.1 1997/05/25 19:49:29 wpaul Exp $ |
33 */ 34 35/* 36 * What follows is a special version of clntudp_call() that has been 37 * hacked to send requests and receive replies asynchronously. Similar 38 * magic is used inside rpc.nisd(8) for the special non-blocking, 39 * non-fork()ing, non-threading callback support. 40 */ --- 25 unchanged lines hidden (view full) --- 66 * Sun Microsystems, Inc. 67 * 2550 Garcia Avenue 68 * Mountain View, California 94043 69 */ 70 71#ifndef lint 72/*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/ 73/*static char *sccsid = "from: @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";*/ | 33 */ 34 35/* 36 * What follows is a special version of clntudp_call() that has been 37 * hacked to send requests and receive replies asynchronously. Similar 38 * magic is used inside rpc.nisd(8) for the special non-blocking, 39 * non-fork()ing, non-threading callback support. 40 */ --- 25 unchanged lines hidden (view full) --- 66 * Sun Microsystems, Inc. 67 * 2550 Garcia Avenue 68 * Mountain View, California 94043 69 */ 70 71#ifndef lint 72/*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/ 73/*static char *sccsid = "from: @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";*/ |
74static const char rcsid[] = "@(#) $Id: yp_ping.c,v 1.2 1997/05/25 18:54:11 wpaul Exp wpaul $"; | 74static const char rcsid[] = "@(#) $Id: yp_ping.c,v 1.1 1997/05/25 19:49:29 wpaul Exp $"; |
75#endif 76 77/* 78 * clnt_udp.c, Implements a UDP/IP based, client side RPC. 79 * 80 * Copyright (C) 1984, Sun Microsystems, Inc. 81 */ 82 --- 370 unchanged lines hidden (view full) --- 453 struct sockaddr_in sin, *any; 454 int winner = -1; 455 time_t xid_seed, xid_lookup; 456 int sock, dontblock = 1; 457 CLIENT *clnt; 458 char *foo = dom; 459 struct cu_data *cu; 460 enum clnt_stat (*oldfunc)(); | 75#endif 76 77/* 78 * clnt_udp.c, Implements a UDP/IP based, client side RPC. 79 * 80 * Copyright (C) 1984, Sun Microsystems, Inc. 81 */ 82 --- 370 unchanged lines hidden (view full) --- 453 struct sockaddr_in sin, *any; 454 int winner = -1; 455 time_t xid_seed, xid_lookup; 456 int sock, dontblock = 1; 457 CLIENT *clnt; 458 char *foo = dom; 459 struct cu_data *cu; 460 enum clnt_stat (*oldfunc)(); |
461 int validsrvs = 0; |
|
461 462 /* Set up handles. */ 463 reqs = calloc(1, sizeof(struct ping_req *) * cnt); 464 xid_seed = time(NULL) ^ getpid(); 465 466 for (i = 0; i < cnt; i++) { 467 bzero((char *)&sin, sizeof(sin)); 468 sin.sin_family = AF_INET; 469 bcopy((char *)&restricted_addrs[i], 470 (char *)&sin.sin_addr, sizeof(struct in_addr)); 471 sin.sin_port = htons(__pmap_getport(&sin, YPPROG, 472 YPVERS, IPPROTO_UDP)); 473 if (sin.sin_port == 0) 474 continue; 475 reqs[i] = calloc(1, sizeof(struct ping_req)); 476 bcopy((char *)&sin, (char *)&reqs[i]->sin, sizeof(sin)); 477 any = &reqs[i]->sin; 478 reqs[i]->xid = xid_seed; 479 xid_seed++; | 462 463 /* Set up handles. */ 464 reqs = calloc(1, sizeof(struct ping_req *) * cnt); 465 xid_seed = time(NULL) ^ getpid(); 466 467 for (i = 0; i < cnt; i++) { 468 bzero((char *)&sin, sizeof(sin)); 469 sin.sin_family = AF_INET; 470 bcopy((char *)&restricted_addrs[i], 471 (char *)&sin.sin_addr, sizeof(struct in_addr)); 472 sin.sin_port = htons(__pmap_getport(&sin, YPPROG, 473 YPVERS, IPPROTO_UDP)); 474 if (sin.sin_port == 0) 475 continue; 476 reqs[i] = calloc(1, sizeof(struct ping_req)); 477 bcopy((char *)&sin, (char *)&reqs[i]->sin, sizeof(sin)); 478 any = &reqs[i]->sin; 479 reqs[i]->xid = xid_seed; 480 xid_seed++; |
481 validsrvs++; |
|
480 } 481 482 /* Make sure at least one server was assigned */ | 482 } 483 484 /* Make sure at least one server was assigned */ |
483 if (reqs[0] == NULL) { | 485 if (!validsrvs) { |
484 free(reqs); 485 return(-1); 486 } 487 488 /* Create RPC handle */ 489 sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); 490 clnt = clntudp_create(any, YPPROG, YPVERS, tv, &sock); 491 if (clnt == NULL) { --- 51 unchanged lines hidden --- | 486 free(reqs); 487 return(-1); 488 } 489 490 /* Create RPC handle */ 491 sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); 492 clnt = clntudp_create(any, YPPROG, YPVERS, tv, &sock); 493 if (clnt == NULL) { --- 51 unchanged lines hidden --- |