clnt_dg.c (f249dbcc7149848de00cd8f4e93fe140dfa3f219) clnt_dg.c (cffc0b5784e3c021ce62c949f9a3859da4764dd5)
1/* $NetBSD: clnt_dg.c,v 1.4 2000/07/14 08:40:41 fvdl Exp $ */
2
3/*
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or

--- 59 unchanged lines hidden (view full) ---

68
69static struct clnt_ops *clnt_dg_ops(void);
70static bool_t time_not_ok(struct timeval *);
71static enum clnt_stat clnt_dg_call(CLIENT *, rpcproc_t, xdrproc_t, void *,
72 xdrproc_t, void *, struct timeval);
73static void clnt_dg_geterr(CLIENT *, struct rpc_err *);
74static bool_t clnt_dg_freeres(CLIENT *, xdrproc_t, void *);
75static void clnt_dg_abort(CLIENT *);
1/* $NetBSD: clnt_dg.c,v 1.4 2000/07/14 08:40:41 fvdl Exp $ */
2
3/*
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or

--- 59 unchanged lines hidden (view full) ---

68
69static struct clnt_ops *clnt_dg_ops(void);
70static bool_t time_not_ok(struct timeval *);
71static enum clnt_stat clnt_dg_call(CLIENT *, rpcproc_t, xdrproc_t, void *,
72 xdrproc_t, void *, struct timeval);
73static void clnt_dg_geterr(CLIENT *, struct rpc_err *);
74static bool_t clnt_dg_freeres(CLIENT *, xdrproc_t, void *);
75static void clnt_dg_abort(CLIENT *);
76static bool_t clnt_dg_control(CLIENT *, u_int, char *);
76static bool_t clnt_dg_control(CLIENT *, u_int, void *);
77static void clnt_dg_destroy(CLIENT *);
78static int __rpc_timeval_to_msec(struct timeval *);
79
80
81
82
83/*
84 * This machinery implements per-fd locks for MT-safety. It is not

--- 536 unchanged lines hidden (view full) ---

621 CLIENT *h;
622{
623}
624
625static bool_t
626clnt_dg_control(cl, request, info)
627 CLIENT *cl;
628 u_int request;
77static void clnt_dg_destroy(CLIENT *);
78static int __rpc_timeval_to_msec(struct timeval *);
79
80
81
82
83/*
84 * This machinery implements per-fd locks for MT-safety. It is not

--- 536 unchanged lines hidden (view full) ---

621 CLIENT *h;
622{
623}
624
625static bool_t
626clnt_dg_control(cl, request, info)
627 CLIENT *cl;
628 u_int request;
629 char *info;
629 void *info;
630{
631 struct cu_data *cu = (struct cu_data *)cl->cl_private;
632 struct netbuf *addr;
633 sigset_t mask;
634 sigset_t newmask;
635 int rpc_lock_value;
636
637 sigfillset(&newmask);

--- 20 unchanged lines hidden (view full) ---

658
659 /* for other requests which use info */
660 if (info == NULL) {
661 release_fd_lock(cu->cu_fd, mask);
662 return (FALSE);
663 }
664 switch (request) {
665 case CLSET_TIMEOUT:
630{
631 struct cu_data *cu = (struct cu_data *)cl->cl_private;
632 struct netbuf *addr;
633 sigset_t mask;
634 sigset_t newmask;
635 int rpc_lock_value;
636
637 sigfillset(&newmask);

--- 20 unchanged lines hidden (view full) ---

658
659 /* for other requests which use info */
660 if (info == NULL) {
661 release_fd_lock(cu->cu_fd, mask);
662 return (FALSE);
663 }
664 switch (request) {
665 case CLSET_TIMEOUT:
666 if (time_not_ok((struct timeval *)(void *)info)) {
666 if (time_not_ok((struct timeval *)info)) {
667 release_fd_lock(cu->cu_fd, mask);
668 return (FALSE);
669 }
667 release_fd_lock(cu->cu_fd, mask);
668 return (FALSE);
669 }
670 cu->cu_total = *(struct timeval *)(void *)info;
670 cu->cu_total = *(struct timeval *)info;
671 break;
672 case CLGET_TIMEOUT:
671 break;
672 case CLGET_TIMEOUT:
673 *(struct timeval *)(void *)info = cu->cu_total;
673 *(struct timeval *)info = cu->cu_total;
674 break;
675 case CLGET_SERVER_ADDR: /* Give him the fd address */
676 /* Now obsolete. Only for backward compatibility */
677 (void) memcpy(info, &cu->cu_raddr, (size_t)cu->cu_rlen);
678 break;
679 case CLSET_RETRY_TIMEOUT:
674 break;
675 case CLGET_SERVER_ADDR: /* Give him the fd address */
676 /* Now obsolete. Only for backward compatibility */
677 (void) memcpy(info, &cu->cu_raddr, (size_t)cu->cu_rlen);
678 break;
679 case CLSET_RETRY_TIMEOUT:
680 if (time_not_ok((struct timeval *)(void *)info)) {
680 if (time_not_ok((struct timeval *)info)) {
681 release_fd_lock(cu->cu_fd, mask);
682 return (FALSE);
683 }
681 release_fd_lock(cu->cu_fd, mask);
682 return (FALSE);
683 }
684 cu->cu_wait = *(struct timeval *)(void *)info;
684 cu->cu_wait = *(struct timeval *)info;
685 break;
686 case CLGET_RETRY_TIMEOUT:
685 break;
686 case CLGET_RETRY_TIMEOUT:
687 *(struct timeval *)(void *)info = cu->cu_wait;
687 *(struct timeval *)info = cu->cu_wait;
688 break;
689 case CLGET_FD:
688 break;
689 case CLGET_FD:
690 *(int *)(void *)info = cu->cu_fd;
690 *(int *)info = cu->cu_fd;
691 break;
692 case CLGET_SVC_ADDR:
691 break;
692 case CLGET_SVC_ADDR:
693 addr = (struct netbuf *)(void *)info;
693 addr = (struct netbuf *)info;
694 addr->buf = &cu->cu_raddr;
695 addr->len = cu->cu_rlen;
696 addr->maxlen = sizeof cu->cu_raddr;
697 break;
698 case CLSET_SVC_ADDR: /* set to new address */
694 addr->buf = &cu->cu_raddr;
695 addr->len = cu->cu_rlen;
696 addr->maxlen = sizeof cu->cu_raddr;
697 break;
698 case CLSET_SVC_ADDR: /* set to new address */
699 addr = (struct netbuf *)(void *)info;
699 addr = (struct netbuf *)info;
700 if (addr->len < sizeof cu->cu_raddr) {
701 release_fd_lock(cu->cu_fd, mask);
702 return (FALSE);
703 }
704 (void) memcpy(&cu->cu_raddr, addr->buf, addr->len);
705 cu->cu_rlen = addr->len;
706 break;
707 case CLGET_XID:
708 /*
709 * use the knowledge that xid is the
710 * first element in the call structure *.
711 * This will get the xid of the PREVIOUS call
712 */
700 if (addr->len < sizeof cu->cu_raddr) {
701 release_fd_lock(cu->cu_fd, mask);
702 return (FALSE);
703 }
704 (void) memcpy(&cu->cu_raddr, addr->buf, addr->len);
705 cu->cu_rlen = addr->len;
706 break;
707 case CLGET_XID:
708 /*
709 * use the knowledge that xid is the
710 * first element in the call structure *.
711 * This will get the xid of the PREVIOUS call
712 */
713 *(u_int32_t *)(void *)info =
713 *(u_int32_t *)info =
714 ntohl(*(u_int32_t *)(void *)cu->cu_outbuf);
715 break;
716
717 case CLSET_XID:
718 /* This will set the xid of the NEXT call */
719 *(u_int32_t *)(void *)cu->cu_outbuf =
714 ntohl(*(u_int32_t *)(void *)cu->cu_outbuf);
715 break;
716
717 case CLSET_XID:
718 /* This will set the xid of the NEXT call */
719 *(u_int32_t *)(void *)cu->cu_outbuf =
720 htonl(*(u_int32_t *)(void *)info - 1);
720 htonl(*(u_int32_t *)info - 1);
721 /* decrement by 1 as clnt_dg_call() increments once */
722 break;
723
724 case CLGET_VERS:
725 /*
726 * This RELIES on the information that, in the call body,
727 * the version number field is the fifth field from the
728 * begining of the RPC header. MUST be changed if the
729 * call_struct is changed
730 */
721 /* decrement by 1 as clnt_dg_call() increments once */
722 break;
723
724 case CLGET_VERS:
725 /*
726 * This RELIES on the information that, in the call body,
727 * the version number field is the fifth field from the
728 * begining of the RPC header. MUST be changed if the
729 * call_struct is changed
730 */
731 *(u_int32_t *)(void *)info =
731 *(u_int32_t *)info =
732 ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf +
733 4 * BYTES_PER_XDR_UNIT));
734 break;
735
736 case CLSET_VERS:
737 *(u_int32_t *)(void *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT)
732 ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf +
733 4 * BYTES_PER_XDR_UNIT));
734 break;
735
736 case CLSET_VERS:
737 *(u_int32_t *)(void *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT)
738 = htonl(*(u_int32_t *)(void *)info);
738 = htonl(*(u_int32_t *)info);
739 break;
740
741 case CLGET_PROG:
742 /*
743 * This RELIES on the information that, in the call body,
744 * the program number field is the fourth field from the
745 * begining of the RPC header. MUST be changed if the
746 * call_struct is changed
747 */
739 break;
740
741 case CLGET_PROG:
742 /*
743 * This RELIES on the information that, in the call body,
744 * the program number field is the fourth field from the
745 * begining of the RPC header. MUST be changed if the
746 * call_struct is changed
747 */
748 *(u_int32_t *)(void *)info =
748 *(u_int32_t *)info =
749 ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf +
750 3 * BYTES_PER_XDR_UNIT));
751 break;
752
753 case CLSET_PROG:
754 *(u_int32_t *)(void *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT)
749 ntohl(*(u_int32_t *)(void *)(cu->cu_outbuf +
750 3 * BYTES_PER_XDR_UNIT));
751 break;
752
753 case CLSET_PROG:
754 *(u_int32_t *)(void *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT)
755 = htonl(*(u_int32_t *)(void *)info);
755 = htonl(*(u_int32_t *)info);
756 break;
757 case CLSET_ASYNC:
756 break;
757 case CLSET_ASYNC:
758 cu->cu_async = *(int *)(void *)info;
758 cu->cu_async = *(int *)info;
759 break;
760 case CLSET_CONNECT:
759 break;
760 case CLSET_CONNECT:
761 cu->cu_connect = *(int *)(void *)info;
761 cu->cu_connect = *(int *)info;
762 break;
763 default:
764 release_fd_lock(cu->cu_fd, mask);
765 return (FALSE);
766 }
767 release_fd_lock(cu->cu_fd, mask);
768 return (TRUE);
769}

--- 89 unchanged lines hidden ---
762 break;
763 default:
764 release_fd_lock(cu->cu_fd, mask);
765 return (FALSE);
766 }
767 release_fd_lock(cu->cu_fd, mask);
768 return (TRUE);
769}

--- 89 unchanged lines hidden ---