clnt_generic.c (0cc39166733d7a7eee94bd8aa573237a90d9838e) | clnt_generic.c (54edc0bbbfcc1123b31fa29f3502bb25e5769d93) |
---|---|
1/* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. | 1/* 2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3 * unrestricted use provided that this legend is included on all tape 4 * media and as a part of the software program in whole or part. Users 5 * may copy or modify Sun RPC without charge, but are not authorized 6 * to license or distribute it to anyone else except as part of a product or 7 * program developed by the user. |
8 * | 8 * |
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. | 9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. |
12 * | 12 * |
13 * Sun RPC is provided with no support and without any obligation on the 14 * part of Sun Microsystems, Inc. to assist in its use, correction, 15 * modification or enhancement. 16 * 17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 * OR ANY PART THEREOF. | 13 * Sun RPC is provided with no support and without any obligation on the 14 * part of Sun Microsystems, Inc. to assist in its use, correction, 15 * modification or enhancement. 16 * 17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19 * OR ANY PART THEREOF. |
20 * | 20 * |
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 * or profits or other special, indirect and consequential damages, even if 23 * Sun has been advised of the possibility of such damages. | 21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22 * or profits or other special, indirect and consequential damages, even if 23 * Sun has been advised of the possibility of such damages. |
24 * | 24 * |
25 * Sun Microsystems, Inc. 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31/*static char *sccsid = "from: @(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";*/ 32/*static char *sccsid = "from: @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC";*/ | 25 * Sun Microsystems, Inc. 26 * 2550 Garcia Avenue 27 * Mountain View, California 94043 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31/*static char *sccsid = "from: @(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";*/ 32/*static char *sccsid = "from: @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC";*/ |
33static char *rcsid = "$Id: clnt_generic.c,v 1.1 1993/10/27 05:40:19 paul Exp $"; | 33static char *rcsid = "$Id: clnt_generic.c,v 1.3 1995/10/22 14:51:12 phk Exp $"; |
34#endif 35 36/* 37 * Copyright (C) 1987, Sun Microsystems, Inc. 38 */ 39#include <rpc/rpc.h> 40#include <sys/socket.h> 41#include <sys/errno.h> 42#include <netdb.h> | 34#endif 35 36/* 37 * Copyright (C) 1987, Sun Microsystems, Inc. 38 */ 39#include <rpc/rpc.h> 40#include <sys/socket.h> 41#include <sys/errno.h> 42#include <netdb.h> |
43#include <string.h> |
|
43 44/* 45 * Generic client creation: takes (hostname, program-number, protocol) and | 44 45/* 46 * Generic client creation: takes (hostname, program-number, protocol) and |
46 * returns client handle. Default options are set, which the user can | 47 * returns client handle. Default options are set, which the user can |
47 * change using the rpc equivalent of ioctl()'s. 48 */ 49CLIENT * 50clnt_create(hostname, prog, vers, proto) 51 char *hostname; 52 u_long prog; 53 u_long vers; 54 char *proto; --- 10 unchanged lines hidden (view full) --- 65 rpc_createerr.cf_stat = RPC_UNKNOWNHOST; 66 return (NULL); 67 } 68 if (h->h_addrtype != AF_INET) { 69 /* 70 * Only support INET for now 71 */ 72 rpc_createerr.cf_stat = RPC_SYSTEMERROR; | 48 * change using the rpc equivalent of ioctl()'s. 49 */ 50CLIENT * 51clnt_create(hostname, prog, vers, proto) 52 char *hostname; 53 u_long prog; 54 u_long vers; 55 char *proto; --- 10 unchanged lines hidden (view full) --- 66 rpc_createerr.cf_stat = RPC_UNKNOWNHOST; 67 return (NULL); 68 } 69 if (h->h_addrtype != AF_INET) { 70 /* 71 * Only support INET for now 72 */ 73 rpc_createerr.cf_stat = RPC_SYSTEMERROR; |
73 rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; | 74 rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; |
74 return (NULL); 75 } | 75 return (NULL); 76 } |
77 memset(&sin, 0, sizeof(sin)); 78 sin.sin_len = sizeof(struct sockaddr_in); |
|
76 sin.sin_family = h->h_addrtype; 77 sin.sin_port = 0; 78 bzero(sin.sin_zero, sizeof(sin.sin_zero)); 79 bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length); 80 p = getprotobyname(proto); 81 if (p == NULL) { 82 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; | 79 sin.sin_family = h->h_addrtype; 80 sin.sin_port = 0; 81 bzero(sin.sin_zero, sizeof(sin.sin_zero)); 82 bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length); 83 p = getprotobyname(proto); 84 if (p == NULL) { 85 rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; |
83 rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; | 86 rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; |
84 return (NULL); 85 } 86 sock = RPC_ANYSOCK; 87 switch (p->p_proto) { 88 case IPPROTO_UDP: 89 tv.tv_sec = 5; 90 tv.tv_usec = 0; 91 client = clntudp_create(&sin, prog, vers, tv, &sock); --- 9 unchanged lines hidden (view full) --- 101 return (NULL); 102 } 103 tv.tv_sec = 25; 104 tv.tv_usec = 0; 105 clnt_control(client, CLSET_TIMEOUT, &tv); 106 break; 107 default: 108 rpc_createerr.cf_stat = RPC_SYSTEMERROR; | 87 return (NULL); 88 } 89 sock = RPC_ANYSOCK; 90 switch (p->p_proto) { 91 case IPPROTO_UDP: 92 tv.tv_sec = 5; 93 tv.tv_usec = 0; 94 client = clntudp_create(&sin, prog, vers, tv, &sock); --- 9 unchanged lines hidden (view full) --- 104 return (NULL); 105 } 106 tv.tv_sec = 25; 107 tv.tv_usec = 0; 108 clnt_control(client, CLSET_TIMEOUT, &tv); 109 break; 110 default: 111 rpc_createerr.cf_stat = RPC_SYSTEMERROR; |
109 rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; | 112 rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; |
110 return (NULL); 111 } 112 return (client); 113} | 113 return (NULL); 114 } 115 return (client); 116} |