1 /* $NetBSD: yppush_svc.c,v 1.8 2009/04/19 06:06:40 lukem Exp $ */
4 * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
31 __RCSID("$NetBSD: yppush_svc.c,v 1.8 2009/04/19 06:06:40 lukem Exp $");
35 * Originally from an rpcgen-generated file, then cleaned up
36 * by Jason R. Thorpe <thorpej@NetBSD.org>.
39 #include <sys/types.h>
40 #include <sys/socket.h>
42 #include <netinet/in.h>
54 #include <rpcsvc/yp_prot.h>
62 #define _RPCSVC_CLOSEDOWN 120
63 int _rpcpmstart
; /* Started by a port monitor ? */
64 int _rpcfdtype
; /* Whether Stream or Datagram ? */
65 int _rpcsvcdirty
; /* Still serving ? */
67 static void _msgout(const char *);
70 void _msgout(const char *msg
)
74 syslog(LOG_ERR
, "%s", msg
);
78 syslog(LOG_ERR
, "%s", msg
);
83 yppush_xfrrespprog_1(struct svc_req
*rqstp
, SVCXPRT
*transp
)
86 struct yppushresp_xfr yppushproc_xfrresp_1_arg
;
89 xdrproc_t xdr_argument
, xdr_result
;
90 void *(*local
)(void *, struct svc_req
*);
93 switch (rqstp
->rq_proc
) {
95 xdr_argument
= xdr_void
;
96 xdr_result
= xdr_void
;
97 local
= yppushproc_null_1_svc
;
100 case YPPUSHPROC_XFRRESP
:
101 xdr_argument
= xdr_yppushresp_xfr
;
102 xdr_result
= xdr_void
;
103 local
= yppushproc_xfrresp_1_svc
;
107 svcerr_noproc(transp
);
113 (void) memset((char *)&argument
, 0, sizeof (argument
));
114 if (!svc_getargs(transp
, xdr_argument
, (caddr_t
) &argument
)) {
115 svcerr_decode(transp
);
121 result
= (*local
)(&argument
, rqstp
);
122 if (result
!= NULL
&& !svc_sendreply(transp
, xdr_result
, result
))
123 svcerr_systemerr(transp
);
125 if (!svc_freeargs(transp
, xdr_argument
, (caddr_t
) &argument
)) {
126 _msgout("unable to free arguments");
130 if (rqstp
->rq_proc
!= YPPUSHPROC_NULL
)