-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdsitest.c
153 lines (131 loc) · 4.36 KB
/
dsitest.c
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
#include <AppleTalk.h>
#include <locator.h>
#include <tcpip.h>
#include <stdio.h>
#include <orca.h>
#include "aspinterface.h"
#include "atipmapping.h"
#include "endian.h"
ASPGetStatusRec getStatusRec;
ASPOpenSessionRec openSessionRec;
ASPCommandRec commandRec;
ASPWriteRec writeRec;
ASPCloseSessionRec closeSessionRec;
Byte replyBuffer[1024];
struct FPFlushRec {
Byte CommandCode;
Byte Pad;
Word VolumeID;
} fpFlushRec;
struct FPWriteRec {
Byte CommandCode;
Byte Flag;
Word OForkRefNum;
LongWord Offset;
LongWord ReqCount;
} fpWriteRec;
#define kFPFlush 10
#define kFPWrite 33
int main(int argc, char **argv)
{
Boolean loadedTCP = FALSE;
Boolean startedTCP = FALSE;
cvtRec myCvtRec;
int i;
TLStartUp();
if (!TCPIPStatus()) {
LoadOneTool(54, 0x0300); /* load Marinetti 3.0+ */
if (toolerror())
goto error;
loadedTCP = TRUE;
TCPIPStartUp();
if (toolerror())
goto error;
startedTCP = TRUE;
}
atipMapping.networkNumber = 0xFFFF;
atipMapping.node = 0xFF;
atipMapping.socket = 0xFF;
TCPIPConvertIPCToHex(&myCvtRec, argv[1]);
atipMapping.ipAddr = myCvtRec.cvtIPAddress;
atipMapping.port = 548;
// Do the call
getStatusRec.async = AT_SYNC;
getStatusRec.command = aspGetStatusCommand;
getStatusRec.completionPtr = 0;
getStatusRec.slsNet = atipMapping.networkNumber;
getStatusRec.slsNode = atipMapping.node;
getStatusRec.slsSocket = atipMapping.socket;
getStatusRec.bufferLength = sizeof(replyBuffer);
getStatusRec.bufferAddr = (LongWord)&replyBuffer;
DispatchASPCommand((SPCommandRec *)&getStatusRec);
#if 0
for (i=0; i<getStatusRec.dataLength;i++) {
printf("%02x ", replyBuffer[i]);
if ((i+1)%16 == 0) printf("\n");
}
printf("\n");
#endif
for (i=0; i<getStatusRec.dataLength;i++) {
if (replyBuffer[i] >= ' ' && replyBuffer[i] <= 126)
printf("%c", replyBuffer[i]);
else
printf(" ");
}
printf("\n");
openSessionRec.async = AT_SYNC;
openSessionRec.command = aspOpenSessionCommand;
openSessionRec.completionPtr = 0;
openSessionRec.slsNet = atipMapping.networkNumber;
openSessionRec.slsNode = atipMapping.node;
openSessionRec.slsSocket = atipMapping.socket;
openSessionRec.attnRtnAddr = NULL; // not used for now
printf("Opening...\n");
DispatchASPCommand((SPCommandRec *)&openSessionRec);
printf("refnum = %i\n", openSessionRec.refNum);
printf("result code = %04x\n", openSessionRec.result);
if (openSessionRec.result)
goto error;
writeRec.async = AT_SYNC;
writeRec.command = aspWriteCommand;
writeRec.completionPtr = 0;
writeRec.refNum = openSessionRec.refNum;
writeRec.cmdBlkLength = sizeof(fpWriteRec);
writeRec.cmdBlkAddr = (LongWord)&fpWriteRec;
fpWriteRec.CommandCode = kFPWrite;
fpWriteRec.ReqCount = htonl(16);
writeRec.writeDataLength = 16;
writeRec.writeDataAddr = (LongWord)&openSessionRec;
writeRec.replyBufferLen = sizeof(replyBuffer);
writeRec.replyBufferAddr = (LongWord)&replyBuffer;
printf("Sending write...\n");
DispatchASPCommand((SPCommandRec *)&writeRec);
printf("result code = %04x, write result = %08lx\n",
writeRec.result, writeRec.cmdResult);
commandRec.async = AT_SYNC;
commandRec.command = aspCommandCommand;
commandRec.completionPtr = 0;
commandRec.refNum = openSessionRec.refNum;
commandRec.cmdBlkLength = sizeof(fpFlushRec);
commandRec.cmdBlkAddr = (LongWord)&fpFlushRec;
fpFlushRec.CommandCode = kFPFlush;
commandRec.replyBufferLen = sizeof(replyBuffer);
commandRec.replyBufferAddr = (LongWord)&replyBuffer;
printf("Sending command...\n");
DispatchASPCommand((SPCommandRec *)&commandRec);
printf("result code = %04x, command result = %08lx\n",
commandRec.result, commandRec.cmdResult);
closeSessionRec.async = AT_SYNC;
closeSessionRec.command = aspCloseSessionCommand;
closeSessionRec.completionPtr = 0;
closeSessionRec.refNum = openSessionRec.refNum;
printf("Closing...\n");
DispatchASPCommand((SPCommandRec *)&closeSessionRec);
printf("result code = %04x\n", closeSessionRec.result);
error:
if (startedTCP)
TCPIPShutDown();
if (loadedTCP)
UnloadOneTool(54);
TLShutDown();
}