summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel <danieruru@gmail.com>2013-01-10 14:59:36 +0900
committerdaniel <danieruru@gmail.com>2013-01-10 14:59:36 +0900
commit7f6453d0778108eed02ea0ff7a87fea3a4b6b34d (patch)
treeb736c8ec5db2d336fddef752658f737c32002895
parent1b91b096d164b5524a45b2585269109fd000fd40 (diff)
add support for the abort channel on the client side
-rw-r--r--instr-daemon.c15
-rw-r--r--libvxi11client/Makefile2
-rw-r--r--libvxi11client/libvxi11client.c37
-rw-r--r--vxi11_server.c1
-rw-r--r--vxi11_svc.c12
5 files changed, 56 insertions, 11 deletions
diff --git a/instr-daemon.c b/instr-daemon.c
index 66cc4d5..9b4e513 100644
--- a/instr-daemon.c
+++ b/instr-daemon.c
@@ -188,6 +188,14 @@ handler (GThreadedSocketService *service,
return TRUE;
}
+extern void vxi_main ();
+
+static gpointer vxithreadfunc (gpointer data){
+ vxi_main ();
+ return NULL;
+}
+
+
int main(int argc, char **argv)
{
@@ -285,7 +293,12 @@ int main(int argc, char **argv)
g_timeout_add (20, (GSourceFunc) periodic_poll, NULL);
g_timeout_add (100, (GSourceFunc) finish_boot, NULL);
- vxi_main ();
+ //GThread *vxithread =(vxithreadfunc, NULL,false, NULL);
+ //if(vxithread == NULL)
+ // printf("Couldn't create vxi thread\n");
+
+ vxi_main();
+
g_main_loop_run (loop);
bus_shutdown();
diff --git a/libvxi11client/Makefile b/libvxi11client/Makefile
index 94c22fc..560fb7a 100644
--- a/libvxi11client/Makefile
+++ b/libvxi11client/Makefile
@@ -1,4 +1,4 @@
-CFLAGS = -Wall
+CFLAGS = -Wall -std=gnu99
all: client
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index 6234c0f..e814fdf 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -1,6 +1,15 @@
#include <stdbool.h>
+#include <rpc/rpc.h>
+#include <netinet/in.h>
#include "vxi11.h"
+#define DEBUG
+
+#ifdef DEBUG
+#include <stdio.h>
+#include <arpa/inet.h>
+#endif
+
/**
* This is a thin wrapper around the rpcgen generated code to give it a simpler interface.
* Only one server with a single link is supported.
@@ -13,6 +22,7 @@
#define VXI11_DEFAULT_TIMEOUT 1000
static CLIENT* clnt = NULL;
+static CLIENT* abortclnt = NULL;
static Device_Link link;
static Device_Flags vxi11_generateflags(bool waitlock, bool end, bool termchrset) {
@@ -33,6 +43,7 @@ static Device_Flags vxi11_generateflags(bool waitlock, bool end, bool termchrset
int vxi11_open(char* address, char* device) {
clnt = clnt_create(address, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
+
if (clnt == NULL)
return 0;
@@ -46,6 +57,30 @@ int vxi11_open(char* address, char* device) {
Create_LinkResp* linkresp = create_link_1(&link_parms, clnt);
if (linkresp != NULL && linkresp->error == 0) {
link = linkresp->lid;
+
+#ifdef DEBUG
+ printf("Link created, abort channel port %d\n", linkresp->abortPort);
+#endif
+
+ struct sockaddr_in serveraddr;
+ if (clnt_control(clnt, CLGET_SERVER_ADDR, (char*) &serveraddr)) {
+
+#ifdef DEBUG
+ char addressstring[INET_ADDRSTRLEN];
+ *inet_ntop(AF_INET, &serveraddr.sin_addr, addressstring, sizeof(addressstring));
+ printf("Remote is %s\n", addressstring);
+#endif
+
+ int sock = RPC_ANYSOCK;
+ abortclnt = clnttcp_create(&serveraddr, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, &sock, 0, 0);
+ if (abortclnt == NULL)
+ return 0;
+
+ }
+ else
+ // failed!
+ return 0;
+
return 1;
}
else if (linkresp == NULL)
@@ -286,7 +321,7 @@ int vxi11_destroy_intr_chan() {
*/
int vxi11_abort() {
- if (clnt == NULL)
+ if (abortclnt == NULL)
return 0;
Device_Error* error = device_abort_1(&link, clnt);
if (error != NULL && error->error == 0)
diff --git a/vxi11_server.c b/vxi11_server.c
index ec2eb95..d5b973d 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -62,6 +62,7 @@ create_link_1_svc(Create_LinkParms *argp, struct svc_req *rqstp) {
static Create_LinkResp result;
globals.Remote.vxi_connections++;
result.error = 0;
+ result.abortPort = 1234;
return &result;
}
diff --git a/vxi11_svc.c b/vxi11_svc.c
index 0db5020..29d63d7 100644
--- a/vxi11_svc.c
+++ b/vxi11_svc.c
@@ -1,8 +1,3 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
#include "vxi11.h"
#include <stdio.h>
#include <stdlib.h>
@@ -236,8 +231,11 @@ device_intr_1(struct svc_req *rqstp, register SVCXPRT *transp)
return;
}
-int vxi_main ()
+void vxi_main ()
{
+
+ printf("VXI service started\n");
+
register SVCXPRT *transp;
pmap_unset (DEVICE_ASYNC, DEVICE_ASYNC_VERSION);
@@ -282,6 +280,4 @@ int vxi_main ()
svc_run ();
fprintf (stderr, "%s", "svc_run returned");
- exit (1);
- /* NOTREACHED */
}