Deleted Added
full compact
transp_sockets.c (42629) transp_sockets.c (51292)
1/*
1/*
2 * Copyright (c) 1997-1998 Erez Zadok
2 * Copyright (c) 1997-1999 Erez Zadok
3 * Copyright (c) 1990 Jan-Simon Pendry
4 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
10 *

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

33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * %W% (Berkeley) %G%
40 *
3 * Copyright (c) 1990 Jan-Simon Pendry
4 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
10 *

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

33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * %W% (Berkeley) %G%
40 *
41 * $Id: transp_sockets.c,v 1.2 1998/11/10 16:23:41 ezk Exp $
41 * $Id: transp_sockets.c,v 1.5 1999/08/22 21:12:31 ezk Exp $
42 *
43 * Socket specific utilities.
44 * -Erez Zadok <ezk@cs.columbia.edu>
45 */
46
47#ifdef HAVE_CONFIG_H
48# include <config.h>
49#endif /* HAVE_CONFIG_H */

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

174struct sockaddr_in *
175amu_svc_getcaller(SVCXPRT *xprt)
176{
177 return svc_getcaller(xprt);
178}
179
180
181/*
42 *
43 * Socket specific utilities.
44 * -Erez Zadok <ezk@cs.columbia.edu>
45 */
46
47#ifdef HAVE_CONFIG_H
48# include <config.h>
49#endif /* HAVE_CONFIG_H */

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

174struct sockaddr_in *
175amu_svc_getcaller(SVCXPRT *xprt)
176{
177 return svc_getcaller(xprt);
178}
179
180
181/*
182 * Bind NFS to a reserved port.
183 */
184static int
185bindnfs_port(int so, u_short *nfs_portp)
186{
187 u_short port;
188 int error = bind_resv_port(so, &port);
189
190 if (error == 0)
191 *nfs_portp = port;
192 return error;
193}
194
195
196/*
197 * Create the nfs service for amd
198 */
199int
200create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp))
201{
202
203 *soNFSp = socket(AF_INET, SOCK_DGRAM, 0);
204
182 * Create the nfs service for amd
183 */
184int
185create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp))
186{
187
188 *soNFSp = socket(AF_INET, SOCK_DGRAM, 0);
189
205 if (*soNFSp < 0 || bindnfs_port(*soNFSp, nfs_portp) < 0) {
190 if (*soNFSp < 0 || bind_resv_port(*soNFSp, NULL) < 0) {
206 plog(XLOG_FATAL, "Can't create privileged nfs port");
207 return 1;
208 }
209 if ((*nfs_xprtp = svcudp_create(*soNFSp)) == NULL) {
210 plog(XLOG_FATAL, "cannot create rpc/udp service");
211 return 2;
212 }
191 plog(XLOG_FATAL, "Can't create privileged nfs port");
192 return 1;
193 }
194 if ((*nfs_xprtp = svcudp_create(*soNFSp)) == NULL) {
195 plog(XLOG_FATAL, "cannot create rpc/udp service");
196 return 2;
197 }
198 if ((*nfs_portp = (*nfs_xprtp)->xp_port) >= IPPORT_RESERVED) {
199 plog(XLOG_FATAL, "Can't create privileged nfs port");
200 return 1;
201 }
213 if (!svc_register(*nfs_xprtp, NFS_PROGRAM, NFS_VERSION, dispatch_fxn, 0)) {
214 plog(XLOG_FATAL, "unable to register (NFS_PROGRAM, NFS_VERSION, 0)");
215 return 3;
216 }
217
218 return 0; /* all is well */
219}
220

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

335 else if (STREQ(proto, "udp"))
336 clnt = clntudp_create(sin, NFS_PROGRAM, nfs_version, tv, &sock);
337 else
338 clnt = NULL;
339
340 if (clnt == NULL) {
341#ifdef HAVE_CLNT_SPCREATEERROR
342 plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s :%s",
202 if (!svc_register(*nfs_xprtp, NFS_PROGRAM, NFS_VERSION, dispatch_fxn, 0)) {
203 plog(XLOG_FATAL, "unable to register (NFS_PROGRAM, NFS_VERSION, 0)");
204 return 3;
205 }
206
207 return 0; /* all is well */
208}
209

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

324 else if (STREQ(proto, "udp"))
325 clnt = clntudp_create(sin, NFS_PROGRAM, nfs_version, tv, &sock);
326 else
327 clnt = NULL;
328
329 if (clnt == NULL) {
330#ifdef HAVE_CLNT_SPCREATEERROR
331 plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s :%s",
343 nfs_version, proto, host, clnt_spcreateerror(""));
332 (int) nfs_version, proto, host, clnt_spcreateerror(""));
344#else /* not HAVE_CLNT_SPCREATEERROR */
345 plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s",
333#else /* not HAVE_CLNT_SPCREATEERROR */
334 plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s",
346 nfs_version, proto, host);
335 (int) nfs_version, proto, host);
347#endif /* not HAVE_CLNT_SPCREATEERROR */
348 return 0;
349 }
350
351 /* Try a couple times to verify the CLIENT handle. */
352 tv.tv_sec = 6;
353 clnt_stat = clnt_call(clnt,
354 NFSPROC_NULL,

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

366 plog(XLOG_INFO, "get_nfs_version trying a lower version");
367 nfs_version = NFS_VERSION;
368 again = 0;
369 }
370 goto try_again;
371#endif /* HAVE_FS_NFS3 */
372 }
373 plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s",
336#endif /* not HAVE_CLNT_SPCREATEERROR */
337 return 0;
338 }
339
340 /* Try a couple times to verify the CLIENT handle. */
341 tv.tv_sec = 6;
342 clnt_stat = clnt_call(clnt,
343 NFSPROC_NULL,

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

355 plog(XLOG_INFO, "get_nfs_version trying a lower version");
356 nfs_version = NFS_VERSION;
357 again = 0;
358 }
359 goto try_again;
360#endif /* HAVE_FS_NFS3 */
361 }
362 plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s",
374 nfs_version, proto, host);
363 (int) nfs_version, proto, host);
375 return 0;
376 }
377
378 plog(XLOG_INFO, "get_nfs_version: returning (%d,%s) on host %s",
364 return 0;
365 }
366
367 plog(XLOG_INFO, "get_nfs_version: returning (%d,%s) on host %s",
379 nfs_version, proto, host);
368 (int) nfs_version, proto, host);
380 return nfs_version;
381}
382
383
384/*
385 * AUTOFS FUNCTIONS FOR SOCKETS:
386 */
387#ifdef HAVE_FS_AUTOFS
388/*
389 * Create the nfs service for amd
390 */
391int
392create_autofs_service(int *soAUTOFSp, u_short *autofs_portp, SVCXPRT **autofs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp))
393{
394 /* NOT IMPLEMENTED! */
395 return -1;
396}
397#endif /* HAVE_FS_AUTOFS */
369 return nfs_version;
370}
371
372
373/*
374 * AUTOFS FUNCTIONS FOR SOCKETS:
375 */
376#ifdef HAVE_FS_AUTOFS
377/*
378 * Create the nfs service for amd
379 */
380int
381create_autofs_service(int *soAUTOFSp, u_short *autofs_portp, SVCXPRT **autofs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp))
382{
383 /* NOT IMPLEMENTED! */
384 return -1;
385}
386#endif /* HAVE_FS_AUTOFS */