summaryrefslogtreecommitdiff
path: root/vxi11_server.c
blob: 84a80d56de3fad1e2da087b7f8bb77d1999571e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
 * 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"
#include "globals.h"
#include <stdbool.h>

#define ERR_SYNTAXERROR 1
#define ERR_DEVICENOTACCESSIBLE 3
#define ERR_INVALIDLINKINDENTIFIER 4
#define ERR_PARAMETERERROR 5
#define ERR_CHANNELNOTESTABLISHED 6
#define ERR_OPERATIONNOTSUPPORTED 8
#define ERR_OUTOFRESOURCES 9
#define ERR_DEVICELOCKEDBYANOTHERLINK 11
#define ERR_NOLOCKHELDBYTHISLINK 12
#define ERR_IOTIMEOUT 15
#define ERR_IOERROR 17
#define ERR_INVALIDADDRESS 21
#define ERR_ABORT 23
#define ERR_CHANNELALREADYESTABLISHED 29

static bool isLocked() {
	return globals.VxiLocks.locked_network_server != NO_SERVER_LOCKED;
}

static bool haveLock(int lid) {
	return globals.VxiLocks.locked_network_server == lid;
}

static void waitForLock(long timeout) {

}

static bool lock(int lid) {
	if (globals.VxiLocks.locked_network_server = NO_SERVER_LOCKED)
		return false;
	globals.VxiLocks.locked_network_server = lid;
}

static bool unlock(int lid) {
	if (globals.VxiLocks.locked_network_server = NO_SERVER_LOCKED)
		return false;
	else if (globals.VxiLocks.locked_network_server != lid)
		return false;
	else {
		globals.VxiLocks.locked_network_server = NO_SERVER_LOCKED;
		return true;
	}
}

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;
	globals.Remote.vxi_connections++;
	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;
	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;

	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;
	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;
	result.error = ERR_OPERATIONNOTSUPPORTED;
	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;
	globals.Remote.vxi_connections--;
	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;
	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;
	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;
	return (void *) &result;
}