summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel <danieruru@gmail.com>2013-01-10 15:26:41 +0900
committerdaniel <danieruru@gmail.com>2013-01-10 15:26:41 +0900
commita7f61f8769d7c704e409e511687d450608c220d1 (patch)
treeb66be102e9c2201693e9173facdb896b7c5dd99e
parent7f6453d0778108eed02ea0ff7a87fea3a4b6b34d (diff)
working abort channel
-rw-r--r--libvxi11client/libvxi11client.c9
-rw-r--r--vxi11_server.c8
2 files changed, 12 insertions, 5 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index e814fdf..f19f81c 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -59,18 +59,17 @@ int vxi11_open(char* address, char* device) {
link = linkresp->lid;
#ifdef DEBUG
- printf("Link created, abort channel port %d\n", linkresp->abortPort);
+ printf("Link created, abort channel port %d\n", ntohs(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
-
+ serveraddr.sin_port = linkresp->abortPort;
int sock = RPC_ANYSOCK;
abortclnt = clnttcp_create(&serveraddr, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, &sock, 0, 0);
if (abortclnt == NULL)
@@ -323,7 +322,7 @@ int vxi11_destroy_intr_chan() {
int vxi11_abort() {
if (abortclnt == NULL)
return 0;
- Device_Error* error = device_abort_1(&link, clnt);
+ Device_Error* error = device_abort_1(&link, abortclnt);
if (error != NULL && error->error == 0)
return 1;
else if (error == NULL)
@@ -343,6 +342,8 @@ int vxi11_close() {
Device_Error* error = destroy_link_1(&link, clnt);
clnt_destroy(clnt);
clnt = NULL;
+ clnt_destroy(abortclnt);
+ abortclnt = NULL;
if (error != NULL && error->error == 0)
return 1;
diff --git a/vxi11_server.c b/vxi11_server.c
index d5b973d..d6007c1 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -8,6 +8,8 @@
#include "stdio.h"
#include "globals.h"
#include <stdbool.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#define ERR_SYNTAXERROR 1
#define ERR_DEVICENOTACCESSIBLE 3
@@ -62,7 +64,11 @@ 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;
+
+ struct sockaddr_in sin;
+ socklen_t len = sizeof(sin);
+ getsockname(rqstp->rq_xprt->xp_sock, (struct sockaddr *) &sin, &len);
+ result.abortPort = sin.sin_port;
return &result;
}