1 AC_DEFUN([ACX_RPCTEST], [
6 AC_REQUIRE([AC_CANONICAL_HOST])
9 AC_SEARCH_LIBS(svcfd_create,nsl,,)
10 AC_SEARCH_LIBS(socket,socket,,)
14 * test-svc-fd -- see if we can use svc_fd
19 #include <sys/select.h>
21 #include <sys/types.h>
22 #include <sys/socket.h>
35 typedef int ShibSocket;
38 typedef unsigned short ShibSockName;
39 #define SHIB_SHAR_SOCKET 12345
41 typedef char* ShibSockName;
42 #define SHIB_SHAR_SOCKET "/tmp/testing-socket"
46 #define UNIX_PATH_MAX 100
49 #ifdef NEED_SVCFD_CREATE_DEFN
50 extern SVCXPRT* svcfd_create ();
53 /* Create a ShibSocket -- return 0 on success; non-zero on error */
55 shib_sock_create (ShibSocket *sock)
57 if (!sock) return EINVAL;
74 /* Bind the socket to the name.
76 * NOTE: This will close the socket on failure
79 shib_sock_bind (ShibSocket s, ShibSockName name)
82 struct sockaddr_in sunaddr;
84 memset (&sunaddr, 0, sizeof (sunaddr));
85 sunaddr.sin_family = AF_INET;
86 sunaddr.sin_addr.s_addr = INADDR_LOOPBACK;
87 sunaddr.sin_port = name;
90 struct sockaddr_un sunaddr;
92 memset (&sunaddr, 0, sizeof (sunaddr));
93 sunaddr.sun_family = AF_UNIX;
94 strncpy (sunaddr.sun_path, name, UNIX_PATH_MAX);
97 if (bind (s, (struct sockaddr *)&sunaddr, sizeof (sunaddr)) < 0) {
103 /* Make sure that only the creator can read -- we don't want just
104 * anyone connecting, do we?
107 if (chmod (name, 0777) < 0) {
121 test_svc_create (ShibSocket sock)
128 * there's an undocumented restriction that the fd you pass in
129 * needs to support the TLI operations.
131 if (ioctl (sock, I_PUSH, "timod") < 0) {
138 /* Wrap an RPC Service around the new connection socket */
139 svc = svcfd_create (sock, 0, 0);
141 perror("svc_fd_create");
142 fprintf (stderr, "Cannot create RPC Listener\n");
150 main (int argc, char *argv[])
155 /* Create the SHAR listener socket */
156 if (shib_sock_create (&sock) != 0)
159 /* Bind to the proper port */
160 if (shib_sock_bind (sock, SHIB_SHAR_SOCKET) != 0)
163 retval = test_svc_create (sock);
165 unlink (SHIB_SHAR_SOCKET);