Ejemplo n.º 1
0
static SVCXPRT *
makefd_xprt(int fd, u_int sendsize, u_int recvsize)
{
	SVCXPRT *xprt;
	struct cf_conn *cd;
	const char *netid;
	struct __rpc_sockinfo si;

	assert(fd != -1);

	xprt = mem_alloc(sizeof(SVCXPRT));
	if (xprt == NULL) {
		warnx("svc_vc: makefd_xprt: out of memory");
		goto done;
	}
	memset(xprt, 0, sizeof *xprt);
	cd = mem_alloc(sizeof(struct cf_conn));
	if (cd == NULL) {
		warnx("svc_tcp: makefd_xprt: out of memory");
		mem_free(xprt, sizeof(SVCXPRT));
		xprt = NULL;
		goto done;
	}
	cd->strm_stat = XPRT_IDLE;
	xdrrec_create(&(cd->xdrs), sendsize, recvsize,
	    xprt, read_vc, write_vc);
	xprt->xp_p1 = cd;
	xprt->xp_verf.oa_base = cd->verf_body;
	svc_vc_ops(xprt);  /* truely deals with calls */
	xprt->xp_port = 0;  /* this is a connection, not a rendezvouser */
	xprt->xp_fd = fd;
        if (__rpc_fd2sockinfo(fd, &si) && __rpc_sockinfo2netid(&si, &netid))
		xprt->xp_netid = strdup(netid);

	xprt_register(xprt);
done:
	return (xprt);
}
Ejemplo n.º 2
0
static int
check_entry (int af, char *ip)
{
  struct __rpc_sockinfo si;
  struct netconfig *nconf = NULL;
  struct netbuf *nbuf;
  const char *netid;
  char uaddr[100];

  snprintf (uaddr, 100, "%s.0.0", ip);

  nbuf = __rpc_uaddr2taddr_af (af, uaddr);
  if (nbuf == NULL)
    {
      fprintf (stderr, "uaddr2taddr (\"%s\") failed\n", ip);
      return 1;
    }

  si.si_af = af;
  si.si_proto = IPPROTO_UDP;
  if (!__rpc_sockinfo2netid (&si, &netid))
    {
      fprintf (stderr, "__rpc_sockinfo2netid() failed\n");
      return 1;
    }
  nconf = getnetconfigent (netid);
  if (nconf == NULL)
    {
      fprintf (stderr, "getnetconfigent (%s) failed\n", netid);
      return 1;
    }
  if (securenet_host (nconf, nbuf) != 1)
    return 1;


  return 0;
}