From 42d30a78def5b5a0f48ce47f0e8cd77eaf8a2452 Mon Sep 17 00:00:00 2001 From: daniel Date: Sat, 5 Jan 2013 16:24:57 +0900 Subject: Wedge the server part of the VXI-11 stuff in here. It doesn't actually do very much at the moment. --- CMakeLists.txt | 3 + instr-daemon.c | 1 + vxi11.h | 342 ++++++++++++++++++++++++++++++++++++++++++ vxi11_server.c | 225 ++++++++++++++++++++++++++++ vxi11_svc.c | 287 +++++++++++++++++++++++++++++++++++ vxi11_xdr.c | 462 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1320 insertions(+) create mode 100644 vxi11.h create mode 100644 vxi11_server.c create mode 100644 vxi11_svc.c create mode 100644 vxi11_xdr.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fe24b6..41fbfca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,9 @@ add_executable(instr-daemon instr-daemon.c menus.c gpib.c dds.c + vxi11_server.c + vxi11_xdr.c + vxi11_svc.c ) add_executable(instr-client instr-client.c) diff --git a/instr-daemon.c b/instr-daemon.c index a74cdbd..66cc4d5 100644 --- a/instr-daemon.c +++ b/instr-daemon.c @@ -285,6 +285,7 @@ int main(int argc, char **argv) g_timeout_add (20, (GSourceFunc) periodic_poll, NULL); g_timeout_add (100, (GSourceFunc) finish_boot, NULL); + vxi_main (); g_main_loop_run (loop); bus_shutdown(); diff --git a/vxi11.h b/vxi11.h new file mode 100644 index 0000000..c21d661 --- /dev/null +++ b/vxi11.h @@ -0,0 +1,342 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _VXI11_H_RPCGEN +#define _VXI11_H_RPCGEN + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef long Device_Link; + +enum Device_AddrFamily { + DEVICE_TCP = 0, + DEVICE_UDP = 1, +}; +typedef enum Device_AddrFamily Device_AddrFamily; + +typedef long Device_Flags; + +typedef long Device_ErrorCode; + +struct Device_Error { + Device_ErrorCode error; +}; +typedef struct Device_Error Device_Error; + +struct Create_LinkParms { + long clientId; + bool_t lockDevice; + u_long lock_timeout; + char *device; +}; +typedef struct Create_LinkParms Create_LinkParms; + +struct Create_LinkResp { + Device_ErrorCode error; + Device_Link lid; + u_short abortPort; + u_long maxRecvSize; +}; +typedef struct Create_LinkResp Create_LinkResp; + +struct Device_WriteParms { + Device_Link lid; + u_long io_timeout; + u_long lock_timeout; + Device_Flags flags; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct Device_WriteParms Device_WriteParms; + +struct Device_WriteResp { + Device_ErrorCode error; + u_long size; +}; +typedef struct Device_WriteResp Device_WriteResp; + +struct Device_ReadParms { + Device_Link lid; + u_long requestSize; + u_long io_timeout; + u_long lock_timeout; + Device_Flags flags; + char termChar; +}; +typedef struct Device_ReadParms Device_ReadParms; + +struct Device_ReadResp { + Device_ErrorCode error; + long reason; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct Device_ReadResp Device_ReadResp; + +struct Device_ReadStbResp { + Device_ErrorCode error; + u_char stb; +}; +typedef struct Device_ReadStbResp Device_ReadStbResp; + +struct Device_GenericParms { + Device_Link lid; + Device_Flags flags; + u_long lock_timeout; + u_long io_timeout; +}; +typedef struct Device_GenericParms Device_GenericParms; + +struct Device_RemoteFunc { + u_long hostAddr; + u_long hostPort; + u_long progNum; + u_long progVers; + Device_AddrFamily progFamily; +}; +typedef struct Device_RemoteFunc Device_RemoteFunc; + +struct Device_EnableSrqParms { + Device_Link lid; + bool_t enable; + struct { + u_int handle_len; + char *handle_val; + } handle; +}; +typedef struct Device_EnableSrqParms Device_EnableSrqParms; + +struct Device_LockParms { + Device_Link lid; + Device_Flags flags; + u_long lock_timeout; +}; +typedef struct Device_LockParms Device_LockParms; + +struct Device_DocmdParms { + Device_Link lid; + Device_Flags flags; + u_long io_timeout; + u_long lock_timeout; + long cmd; + bool_t network_order; + long datasize; + struct { + u_int data_in_len; + char *data_in_val; + } data_in; +}; +typedef struct Device_DocmdParms Device_DocmdParms; + +struct Device_DocmdResp { + Device_ErrorCode error; + struct { + u_int data_out_len; + char *data_out_val; + } data_out; +}; +typedef struct Device_DocmdResp Device_DocmdResp; + +struct Device_SrqParms { + struct { + u_int handle_len; + char *handle_val; + } handle; +}; +typedef struct Device_SrqParms Device_SrqParms; + +#define DEVICE_ASYNC 0x0607B0 +#define DEVICE_ASYNC_VERSION 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define device_abort 1 +extern Device_Error * device_abort_1(Device_Link *, CLIENT *); +extern Device_Error * device_abort_1_svc(Device_Link *, struct svc_req *); +extern int device_async_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define device_abort 1 +extern Device_Error * device_abort_1(); +extern Device_Error * device_abort_1_svc(); +extern int device_async_1_freeresult (); +#endif /* K&R C */ + +#define DEVICE_CORE 0x0607AF +#define DEVICE_CORE_VERSION 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define create_link 10 +extern Create_LinkResp * create_link_1(Create_LinkParms *, CLIENT *); +extern Create_LinkResp * create_link_1_svc(Create_LinkParms *, struct svc_req *); +#define device_write 11 +extern Device_WriteResp * device_write_1(Device_WriteParms *, CLIENT *); +extern Device_WriteResp * device_write_1_svc(Device_WriteParms *, struct svc_req *); +#define device_read 12 +extern Device_ReadResp * device_read_1(Device_ReadParms *, CLIENT *); +extern Device_ReadResp * device_read_1_svc(Device_ReadParms *, struct svc_req *); +#define device_readstb 13 +extern Device_ReadStbResp * device_readstb_1(Device_GenericParms *, CLIENT *); +extern Device_ReadStbResp * device_readstb_1_svc(Device_GenericParms *, struct svc_req *); +#define device_trigger 14 +extern Device_Error * device_trigger_1(Device_GenericParms *, CLIENT *); +extern Device_Error * device_trigger_1_svc(Device_GenericParms *, struct svc_req *); +#define device_clear 15 +extern Device_Error * device_clear_1(Device_GenericParms *, CLIENT *); +extern Device_Error * device_clear_1_svc(Device_GenericParms *, struct svc_req *); +#define device_remote 16 +extern Device_Error * device_remote_1(Device_GenericParms *, CLIENT *); +extern Device_Error * device_remote_1_svc(Device_GenericParms *, struct svc_req *); +#define device_local 17 +extern Device_Error * device_local_1(Device_GenericParms *, CLIENT *); +extern Device_Error * device_local_1_svc(Device_GenericParms *, struct svc_req *); +#define device_lock 18 +extern Device_Error * device_lock_1(Device_LockParms *, CLIENT *); +extern Device_Error * device_lock_1_svc(Device_LockParms *, struct svc_req *); +#define device_unlock 19 +extern Device_Error * device_unlock_1(Device_Link *, CLIENT *); +extern Device_Error * device_unlock_1_svc(Device_Link *, struct svc_req *); +#define device_enable_srq 20 +extern Device_Error * device_enable_srq_1(Device_EnableSrqParms *, CLIENT *); +extern Device_Error * device_enable_srq_1_svc(Device_EnableSrqParms *, struct svc_req *); +#define device_docmd 22 +extern Device_DocmdResp * device_docmd_1(Device_DocmdParms *, CLIENT *); +extern Device_DocmdResp * device_docmd_1_svc(Device_DocmdParms *, struct svc_req *); +#define destroy_link 23 +extern Device_Error * destroy_link_1(Device_Link *, CLIENT *); +extern Device_Error * destroy_link_1_svc(Device_Link *, struct svc_req *); +#define create_intr_chan 25 +extern Device_Error * create_intr_chan_1(Device_RemoteFunc *, CLIENT *); +extern Device_Error * create_intr_chan_1_svc(Device_RemoteFunc *, struct svc_req *); +#define destroy_intr_chan 26 +extern Device_Error * destroy_intr_chan_1(void *, CLIENT *); +extern Device_Error * destroy_intr_chan_1_svc(void *, struct svc_req *); +extern int device_core_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define create_link 10 +extern Create_LinkResp * create_link_1(); +extern Create_LinkResp * create_link_1_svc(); +#define device_write 11 +extern Device_WriteResp * device_write_1(); +extern Device_WriteResp * device_write_1_svc(); +#define device_read 12 +extern Device_ReadResp * device_read_1(); +extern Device_ReadResp * device_read_1_svc(); +#define device_readstb 13 +extern Device_ReadStbResp * device_readstb_1(); +extern Device_ReadStbResp * device_readstb_1_svc(); +#define device_trigger 14 +extern Device_Error * device_trigger_1(); +extern Device_Error * device_trigger_1_svc(); +#define device_clear 15 +extern Device_Error * device_clear_1(); +extern Device_Error * device_clear_1_svc(); +#define device_remote 16 +extern Device_Error * device_remote_1(); +extern Device_Error * device_remote_1_svc(); +#define device_local 17 +extern Device_Error * device_local_1(); +extern Device_Error * device_local_1_svc(); +#define device_lock 18 +extern Device_Error * device_lock_1(); +extern Device_Error * device_lock_1_svc(); +#define device_unlock 19 +extern Device_Error * device_unlock_1(); +extern Device_Error * device_unlock_1_svc(); +#define device_enable_srq 20 +extern Device_Error * device_enable_srq_1(); +extern Device_Error * device_enable_srq_1_svc(); +#define device_docmd 22 +extern Device_DocmdResp * device_docmd_1(); +extern Device_DocmdResp * device_docmd_1_svc(); +#define destroy_link 23 +extern Device_Error * destroy_link_1(); +extern Device_Error * destroy_link_1_svc(); +#define create_intr_chan 25 +extern Device_Error * create_intr_chan_1(); +extern Device_Error * create_intr_chan_1_svc(); +#define destroy_intr_chan 26 +extern Device_Error * destroy_intr_chan_1(); +extern Device_Error * destroy_intr_chan_1_svc(); +extern int device_core_1_freeresult (); +#endif /* K&R C */ + +#define DEVICE_INTR 0x0607B1 +#define DEVICE_INTR_VERSION 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define device_intr_srq 30 +extern void * device_intr_srq_1(Device_SrqParms *, CLIENT *); +extern void * device_intr_srq_1_svc(Device_SrqParms *, struct svc_req *); +extern int device_intr_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define device_intr_srq 30 +extern void * device_intr_srq_1(); +extern void * device_intr_srq_1_svc(); +extern int device_intr_1_freeresult (); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_Device_Link (XDR *, Device_Link*); +extern bool_t xdr_Device_AddrFamily (XDR *, Device_AddrFamily*); +extern bool_t xdr_Device_Flags (XDR *, Device_Flags*); +extern bool_t xdr_Device_ErrorCode (XDR *, Device_ErrorCode*); +extern bool_t xdr_Device_Error (XDR *, Device_Error*); +extern bool_t xdr_Create_LinkParms (XDR *, Create_LinkParms*); +extern bool_t xdr_Create_LinkResp (XDR *, Create_LinkResp*); +extern bool_t xdr_Device_WriteParms (XDR *, Device_WriteParms*); +extern bool_t xdr_Device_WriteResp (XDR *, Device_WriteResp*); +extern bool_t xdr_Device_ReadParms (XDR *, Device_ReadParms*); +extern bool_t xdr_Device_ReadResp (XDR *, Device_ReadResp*); +extern bool_t xdr_Device_ReadStbResp (XDR *, Device_ReadStbResp*); +extern bool_t xdr_Device_GenericParms (XDR *, Device_GenericParms*); +extern bool_t xdr_Device_RemoteFunc (XDR *, Device_RemoteFunc*); +extern bool_t xdr_Device_EnableSrqParms (XDR *, Device_EnableSrqParms*); +extern bool_t xdr_Device_LockParms (XDR *, Device_LockParms*); +extern bool_t xdr_Device_DocmdParms (XDR *, Device_DocmdParms*); +extern bool_t xdr_Device_DocmdResp (XDR *, Device_DocmdResp*); +extern bool_t xdr_Device_SrqParms (XDR *, Device_SrqParms*); + +#else /* K&R C */ +extern bool_t xdr_Device_Link (); +extern bool_t xdr_Device_AddrFamily (); +extern bool_t xdr_Device_Flags (); +extern bool_t xdr_Device_ErrorCode (); +extern bool_t xdr_Device_Error (); +extern bool_t xdr_Create_LinkParms (); +extern bool_t xdr_Create_LinkResp (); +extern bool_t xdr_Device_WriteParms (); +extern bool_t xdr_Device_WriteResp (); +extern bool_t xdr_Device_ReadParms (); +extern bool_t xdr_Device_ReadResp (); +extern bool_t xdr_Device_ReadStbResp (); +extern bool_t xdr_Device_GenericParms (); +extern bool_t xdr_Device_RemoteFunc (); +extern bool_t xdr_Device_EnableSrqParms (); +extern bool_t xdr_Device_LockParms (); +extern bool_t xdr_Device_DocmdParms (); +extern bool_t xdr_Device_DocmdResp (); +extern bool_t xdr_Device_SrqParms (); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_VXI11_H_RPCGEN */ diff --git a/vxi11_server.c b/vxi11_server.c new file mode 100644 index 0000000..cebff63 --- /dev/null +++ b/vxi11_server.c @@ -0,0 +1,225 @@ +/* + * This is sample code generated by rpcgen. + * These are only templates and you can use them + * as a guideline for developing your own functions. + */ + +#include "vxi11.h" +#include "stdio.h" + +Device_Error * +device_abort_1_svc(Device_Link *argp, struct svc_req *rqstp) { + printf("device_abort_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + result.error = 0; + return &result; +} + +Create_LinkResp * +create_link_1_svc(Create_LinkParms *argp, struct svc_req *rqstp) { + printf("create_link_1_svc()\n"); + static Create_LinkResp result; + + /* + * insert server code here + */ + result.error = 0; + return &result; +} + +Device_WriteResp * +device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) { + printf("device_write_1_svc()\n"); + static Device_WriteResp result; + + printf("%s\n", argp->data.data_val); + + /* + * insert server code here + */ + + //result.size = argp->data.data_len; + result.size = 1; + result.error = 0; + return &result; +} + +Device_ReadResp * +device_read_1_svc(Device_ReadParms *argp, struct svc_req *rqstp) { + printf("device_read_1_svc()\n"); + static Device_ReadResp result; + + /* + * insert server code here + */ + + result.data.data_val = "HELLO!"; + result.data.data_len = 7; + result.error = 0; + result.reason = 0x4; + return &result; +} + +Device_ReadStbResp * +device_readstb_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { + printf("device_readstb_1_svc()\n"); + static Device_ReadStbResp result; + + /* + * insert server code here + */ + + result.error = 0; + result.stb = 0; + return &result; +} + +Device_Error * +device_trigger_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { + printf("device_trigger_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + + result.error = 0; + return &result; +} + +Device_Error * +device_clear_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { + printf("device_clear_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + + result.error = 0; + return &result; +} + +Device_Error * +device_remote_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { + printf("device_remote_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + + result.error = 0; + return &result; +} + +Device_Error * +device_local_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { + printf("device_local_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + result.error = 0; + return &result; +} + +Device_Error * +device_lock_1_svc(Device_LockParms *argp, struct svc_req *rqstp) { + printf("device_lock_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + result.error = 0; + return &result; +} + +Device_Error * +device_unlock_1_svc(Device_Link *argp, struct svc_req *rqstp) { + static Device_Error result; + printf("device_unlock_1_svc()\n"); + /* + * insert server code here + */ + result.error = 0; + return &result; +} + +Device_Error * +device_enable_srq_1_svc(Device_EnableSrqParms *argp, struct svc_req *rqstp) { + printf("device_enable_srq_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + + return &result; +} + +Device_DocmdResp * +device_docmd_1_svc(Device_DocmdParms *argp, struct svc_req *rqstp) { + printf("device_docmd_1_svc()\n"); + static Device_DocmdResp result; + + /* + * insert server code here + */ + result.error = 0; + return &result; +} + +Device_Error * +destroy_link_1_svc(Device_Link *argp, struct svc_req *rqstp) { + printf("destroy_link_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + + return &result; +} + +Device_Error * +create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) { + printf("create_intr_chan_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + result.error = 0; + return &result; +} + +Device_Error * +destroy_intr_chan_1_svc(void *argp, struct svc_req *rqstp) { + printf("destroy_intr_chan_1_svc()\n"); + static Device_Error result; + + /* + * insert server code here + */ + result.error = 0; + return &result; +} + +void * +device_intr_srq_1_svc(Device_SrqParms *argp, struct svc_req *rqstp) { + printf("device_intr_srq_1_svc()\n"); + static char * result; + + /* + * insert server code here + */ + + return (void *) &result; +} diff --git a/vxi11_svc.c b/vxi11_svc.c new file mode 100644 index 0000000..0db5020 --- /dev/null +++ b/vxi11_svc.c @@ -0,0 +1,287 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include "vxi11.h" +#include +#include +#include +#include +#include +#include +#include + +#ifndef SIG_PF +#define SIG_PF void(*)(int) +#endif + +static void +device_async_1(struct svc_req *rqstp, register SVCXPRT *transp) +{ + union { + Device_Link device_abort_1_arg; + } argument; + char *result; + xdrproc_t _xdr_argument, _xdr_result; + char *(*local)(char *, struct svc_req *); + + switch (rqstp->rq_proc) { + case NULLPROC: + (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL); + return; + + case device_abort: + _xdr_argument = (xdrproc_t) xdr_Device_Link; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) device_abort_1_svc; + break; + + default: + svcerr_noproc (transp); + return; + } + memset ((char *)&argument, 0, sizeof (argument)); + if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { + svcerr_decode (transp); + return; + } + result = (*local)((char *)&argument, rqstp); + if (result != NULL && !svc_sendreply(transp, (xdrproc_t) _xdr_result, result)) { + svcerr_systemerr (transp); + } + if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { + fprintf (stderr, "%s", "unable to free arguments"); + exit (1); + } + return; +} + +static void +device_core_1(struct svc_req *rqstp, register SVCXPRT *transp) +{ + union { + Create_LinkParms create_link_1_arg; + Device_WriteParms device_write_1_arg; + Device_ReadParms device_read_1_arg; + Device_GenericParms device_readstb_1_arg; + Device_GenericParms device_trigger_1_arg; + Device_GenericParms device_clear_1_arg; + Device_GenericParms device_remote_1_arg; + Device_GenericParms device_local_1_arg; + Device_LockParms device_lock_1_arg; + Device_Link device_unlock_1_arg; + Device_EnableSrqParms device_enable_srq_1_arg; + Device_DocmdParms device_docmd_1_arg; + Device_Link destroy_link_1_arg; + Device_RemoteFunc create_intr_chan_1_arg; + } argument; + char *result; + xdrproc_t _xdr_argument, _xdr_result; + char *(*local)(char *, struct svc_req *); + + switch (rqstp->rq_proc) { + case NULLPROC: + (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL); + return; + + case create_link: + _xdr_argument = (xdrproc_t) xdr_Create_LinkParms; + _xdr_result = (xdrproc_t) xdr_Create_LinkResp; + local = (char *(*)(char *, struct svc_req *)) create_link_1_svc; + break; + + case device_write: + _xdr_argument = (xdrproc_t) xdr_Device_WriteParms; + _xdr_result = (xdrproc_t) xdr_Device_WriteResp; + local = (char *(*)(char *, struct svc_req *)) device_write_1_svc; + break; + + case device_read: + _xdr_argument = (xdrproc_t) xdr_Device_ReadParms; + _xdr_result = (xdrproc_t) xdr_Device_ReadResp; + local = (char *(*)(char *, struct svc_req *)) device_read_1_svc; + break; + + case device_readstb: + _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; + _xdr_result = (xdrproc_t) xdr_Device_ReadStbResp; + local = (char *(*)(char *, struct svc_req *)) device_readstb_1_svc; + break; + + case device_trigger: + _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) device_trigger_1_svc; + break; + + case device_clear: + _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) device_clear_1_svc; + break; + + case device_remote: + _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) device_remote_1_svc; + break; + + case device_local: + _xdr_argument = (xdrproc_t) xdr_Device_GenericParms; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) device_local_1_svc; + break; + + case device_lock: + _xdr_argument = (xdrproc_t) xdr_Device_LockParms; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) device_lock_1_svc; + break; + + case device_unlock: + _xdr_argument = (xdrproc_t) xdr_Device_Link; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) device_unlock_1_svc; + break; + + case device_enable_srq: + _xdr_argument = (xdrproc_t) xdr_Device_EnableSrqParms; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) device_enable_srq_1_svc; + break; + + case device_docmd: + _xdr_argument = (xdrproc_t) xdr_Device_DocmdParms; + _xdr_result = (xdrproc_t) xdr_Device_DocmdResp; + local = (char *(*)(char *, struct svc_req *)) device_docmd_1_svc; + break; + + case destroy_link: + _xdr_argument = (xdrproc_t) xdr_Device_Link; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) destroy_link_1_svc; + break; + + case create_intr_chan: + _xdr_argument = (xdrproc_t) xdr_Device_RemoteFunc; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) create_intr_chan_1_svc; + break; + + case destroy_intr_chan: + _xdr_argument = (xdrproc_t) xdr_void; + _xdr_result = (xdrproc_t) xdr_Device_Error; + local = (char *(*)(char *, struct svc_req *)) destroy_intr_chan_1_svc; + break; + + default: + svcerr_noproc (transp); + return; + } + memset ((char *)&argument, 0, sizeof (argument)); + if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { + svcerr_decode (transp); + return; + } + result = (*local)((char *)&argument, rqstp); + if (result != NULL && !svc_sendreply(transp, (xdrproc_t) _xdr_result, result)) { + svcerr_systemerr (transp); + } + if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { + fprintf (stderr, "%s", "unable to free arguments"); + exit (1); + } + return; +} + +static void +device_intr_1(struct svc_req *rqstp, register SVCXPRT *transp) +{ + union { + Device_SrqParms device_intr_srq_1_arg; + } argument; + char *result; + xdrproc_t _xdr_argument, _xdr_result; + char *(*local)(char *, struct svc_req *); + + switch (rqstp->rq_proc) { + case NULLPROC: + (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL); + return; + + case device_intr_srq: + _xdr_argument = (xdrproc_t) xdr_Device_SrqParms; + _xdr_result = (xdrproc_t) xdr_void; + local = (char *(*)(char *, struct svc_req *)) device_intr_srq_1_svc; + break; + + default: + svcerr_noproc (transp); + return; + } + memset ((char *)&argument, 0, sizeof (argument)); + if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { + svcerr_decode (transp); + return; + } + result = (*local)((char *)&argument, rqstp); + if (result != NULL && !svc_sendreply(transp, (xdrproc_t) _xdr_result, result)) { + svcerr_systemerr (transp); + } + if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) { + fprintf (stderr, "%s", "unable to free arguments"); + exit (1); + } + return; +} + +int vxi_main () +{ + register SVCXPRT *transp; + + pmap_unset (DEVICE_ASYNC, DEVICE_ASYNC_VERSION); + pmap_unset (DEVICE_CORE, DEVICE_CORE_VERSION); + pmap_unset (DEVICE_INTR, DEVICE_INTR_VERSION); + + transp = svcudp_create(RPC_ANYSOCK); + if (transp == NULL) { + fprintf (stderr, "%s", "cannot create udp service."); + exit(1); + } + if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_UDP)) { + fprintf (stderr, "%s", "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, udp)."); + exit(1); + } + if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_UDP)) { + fprintf (stderr, "%s", "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, udp)."); + exit(1); + } + if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, IPPROTO_UDP)) { + fprintf (stderr, "%s", "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, udp)."); + exit(1); + } + + transp = svctcp_create(RPC_ANYSOCK, 0, 0); + if (transp == NULL) { + fprintf (stderr, "%s", "cannot create tcp service."); + exit(1); + } + if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_TCP)) { + fprintf (stderr, "%s", "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, tcp)."); + exit(1); + } + if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_TCP)) { + fprintf (stderr, "%s", "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, tcp)."); + exit(1); + } + if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, IPPROTO_TCP)) { + fprintf (stderr, "%s", "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, tcp)."); + exit(1); + } + + svc_run (); + fprintf (stderr, "%s", "svc_run returned"); + exit (1); + /* NOTREACHED */ +} diff --git a/vxi11_xdr.c b/vxi11_xdr.c new file mode 100644 index 0000000..29d9371 --- /dev/null +++ b/vxi11_xdr.c @@ -0,0 +1,462 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include "vxi11.h" + +bool_t +xdr_Device_Link (XDR *xdrs, Device_Link *objp) +{ + register int32_t *buf; + + if (!xdr_long (xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_AddrFamily (XDR *xdrs, Device_AddrFamily *objp) +{ + register int32_t *buf; + + if (!xdr_enum (xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_Flags (XDR *xdrs, Device_Flags *objp) +{ + register int32_t *buf; + + if (!xdr_long (xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_ErrorCode (XDR *xdrs, Device_ErrorCode *objp) +{ + register int32_t *buf; + + if (!xdr_long (xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_Error (XDR *xdrs, Device_Error *objp) +{ + register int32_t *buf; + + if (!xdr_Device_ErrorCode (xdrs, &objp->error)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Create_LinkParms (XDR *xdrs, Create_LinkParms *objp) +{ + register int32_t *buf; + + + if (xdrs->x_op == XDR_ENCODE) { + buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_long (xdrs, &objp->clientId)) + return FALSE; + if (!xdr_bool (xdrs, &objp->lockDevice)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + + } else { + IXDR_PUT_LONG(buf, objp->clientId); + IXDR_PUT_BOOL(buf, objp->lockDevice); + IXDR_PUT_U_LONG(buf, objp->lock_timeout); + } + if (!xdr_string (xdrs, &objp->device, ~0)) + return FALSE; + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_long (xdrs, &objp->clientId)) + return FALSE; + if (!xdr_bool (xdrs, &objp->lockDevice)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + + } else { + objp->clientId = IXDR_GET_LONG(buf); + objp->lockDevice = IXDR_GET_BOOL(buf); + objp->lock_timeout = IXDR_GET_U_LONG(buf); + } + if (!xdr_string (xdrs, &objp->device, ~0)) + return FALSE; + return TRUE; + } + + if (!xdr_long (xdrs, &objp->clientId)) + return FALSE; + if (!xdr_bool (xdrs, &objp->lockDevice)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + if (!xdr_string (xdrs, &objp->device, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Create_LinkResp (XDR *xdrs, Create_LinkResp *objp) +{ + register int32_t *buf; + + if (!xdr_Device_ErrorCode (xdrs, &objp->error)) + return FALSE; + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_u_short (xdrs, &objp->abortPort)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->maxRecvSize)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_WriteParms (XDR *xdrs, Device_WriteParms *objp) +{ + register int32_t *buf; + + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->io_timeout)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_WriteResp (XDR *xdrs, Device_WriteResp *objp) +{ + register int32_t *buf; + + if (!xdr_Device_ErrorCode (xdrs, &objp->error)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->size)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_ReadParms (XDR *xdrs, Device_ReadParms *objp) +{ + register int32_t *buf; + + + if (xdrs->x_op == XDR_ENCODE) { + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_long (xdrs, &objp->requestSize)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->io_timeout)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + + } else { + IXDR_PUT_U_LONG(buf, objp->requestSize); + IXDR_PUT_U_LONG(buf, objp->io_timeout); + IXDR_PUT_U_LONG(buf, objp->lock_timeout); + } + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + if (!xdr_char (xdrs, &objp->termChar)) + return FALSE; + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_long (xdrs, &objp->requestSize)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->io_timeout)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + + } else { + objp->requestSize = IXDR_GET_U_LONG(buf); + objp->io_timeout = IXDR_GET_U_LONG(buf); + objp->lock_timeout = IXDR_GET_U_LONG(buf); + } + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + if (!xdr_char (xdrs, &objp->termChar)) + return FALSE; + return TRUE; + } + + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->requestSize)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->io_timeout)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + if (!xdr_char (xdrs, &objp->termChar)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_ReadResp (XDR *xdrs, Device_ReadResp *objp) +{ + register int32_t *buf; + + if (!xdr_Device_ErrorCode (xdrs, &objp->error)) + return FALSE; + if (!xdr_long (xdrs, &objp->reason)) + return FALSE; + if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_ReadStbResp (XDR *xdrs, Device_ReadStbResp *objp) +{ + register int32_t *buf; + + if (!xdr_Device_ErrorCode (xdrs, &objp->error)) + return FALSE; + if (!xdr_u_char (xdrs, &objp->stb)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_GenericParms (XDR *xdrs, Device_GenericParms *objp) +{ + register int32_t *buf; + + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->io_timeout)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_RemoteFunc (XDR *xdrs, Device_RemoteFunc *objp) +{ + register int32_t *buf; + + + if (xdrs->x_op == XDR_ENCODE) { + buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_long (xdrs, &objp->hostAddr)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->hostPort)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->progNum)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->progVers)) + return FALSE; + + } else { + IXDR_PUT_U_LONG(buf, objp->hostAddr); + IXDR_PUT_U_LONG(buf, objp->hostPort); + IXDR_PUT_U_LONG(buf, objp->progNum); + IXDR_PUT_U_LONG(buf, objp->progVers); + } + if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily)) + return FALSE; + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_long (xdrs, &objp->hostAddr)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->hostPort)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->progNum)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->progVers)) + return FALSE; + + } else { + objp->hostAddr = IXDR_GET_U_LONG(buf); + objp->hostPort = IXDR_GET_U_LONG(buf); + objp->progNum = IXDR_GET_U_LONG(buf); + objp->progVers = IXDR_GET_U_LONG(buf); + } + if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily)) + return FALSE; + return TRUE; + } + + if (!xdr_u_long (xdrs, &objp->hostAddr)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->hostPort)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->progNum)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->progVers)) + return FALSE; + if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_EnableSrqParms (XDR *xdrs, Device_EnableSrqParms *objp) +{ + register int32_t *buf; + + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_bool (xdrs, &objp->enable)) + return FALSE; + if (!xdr_bytes (xdrs, (char **)&objp->handle.handle_val, (u_int *) &objp->handle.handle_len, 40)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_LockParms (XDR *xdrs, Device_LockParms *objp) +{ + register int32_t *buf; + + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_DocmdParms (XDR *xdrs, Device_DocmdParms *objp) +{ + register int32_t *buf; + + + if (xdrs->x_op == XDR_ENCODE) { + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_long (xdrs, &objp->io_timeout)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + if (!xdr_long (xdrs, &objp->cmd)) + return FALSE; + if (!xdr_bool (xdrs, &objp->network_order)) + return FALSE; + if (!xdr_long (xdrs, &objp->datasize)) + return FALSE; + + } else { + IXDR_PUT_U_LONG(buf, objp->io_timeout); + IXDR_PUT_U_LONG(buf, objp->lock_timeout); + IXDR_PUT_LONG(buf, objp->cmd); + IXDR_PUT_BOOL(buf, objp->network_order); + IXDR_PUT_LONG(buf, objp->datasize); + } + if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) + return FALSE; + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_long (xdrs, &objp->io_timeout)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + if (!xdr_long (xdrs, &objp->cmd)) + return FALSE; + if (!xdr_bool (xdrs, &objp->network_order)) + return FALSE; + if (!xdr_long (xdrs, &objp->datasize)) + return FALSE; + + } else { + objp->io_timeout = IXDR_GET_U_LONG(buf); + objp->lock_timeout = IXDR_GET_U_LONG(buf); + objp->cmd = IXDR_GET_LONG(buf); + objp->network_order = IXDR_GET_BOOL(buf); + objp->datasize = IXDR_GET_LONG(buf); + } + if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) + return FALSE; + return TRUE; + } + + if (!xdr_Device_Link (xdrs, &objp->lid)) + return FALSE; + if (!xdr_Device_Flags (xdrs, &objp->flags)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->io_timeout)) + return FALSE; + if (!xdr_u_long (xdrs, &objp->lock_timeout)) + return FALSE; + if (!xdr_long (xdrs, &objp->cmd)) + return FALSE; + if (!xdr_bool (xdrs, &objp->network_order)) + return FALSE; + if (!xdr_long (xdrs, &objp->datasize)) + return FALSE; + if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_DocmdResp (XDR *xdrs, Device_DocmdResp *objp) +{ + register int32_t *buf; + + if (!xdr_Device_ErrorCode (xdrs, &objp->error)) + return FALSE; + if (!xdr_bytes (xdrs, (char **)&objp->data_out.data_out_val, (u_int *) &objp->data_out.data_out_len, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_Device_SrqParms (XDR *xdrs, Device_SrqParms *objp) +{ + register int32_t *buf; + + if (!xdr_bytes (xdrs, (char **)&objp->handle.handle_val, (u_int *) &objp->handle.handle_len, ~0)) + return FALSE; + return TRUE; +} -- cgit