278
278
HGFS_SESSION_TYPE_INTERNAL, /* This is a static session. */
279
279
} HgfsSessionInfoType;
281
/* HgfsTransportSessionState, used for session status. */
281
/* HgfsSessionState, used for session status. */
283
283
HGFS_SESSION_STATE_OPEN,
284
284
HGFS_SESSION_STATE_CLOSED,
285
285
} HgfsSessionInfoState;
287
typedef struct HgfsSessionInfo {
288
/* Unique session id. */
287
typedef struct HgfsTransportSessionInfo {
288
/* Default session id. */
289
uint64 defaultSessionId;
291
/* Lock to manipulate the list of sessions */
292
MXUserExclLock *sessionArrayLock;
294
/* List of sessions */
295
DblLnkLst_Links sessionArray;
291
297
/* Max packet size that is supported by both client and server. */
292
298
uint32 maxPacketSize;
300
/* Total number of sessions present this transport session*/
294
303
/* Transport session context. */
295
304
void *transportData;
303
312
/* Function callbacks into Hgfs Channels. */
304
313
HgfsServerChannelCallbacks *channelCbTable;
315
Atomic_uint32 refCount; /* Reference count for session. */
317
uint32 channelCapabilities;
318
} HgfsTransportSessionInfo;
320
typedef struct HgfsSessionInfo {
322
DblLnkLst_Links links;
326
/* Unique session id. */
329
/* Max packet size that is supported by both client and server. */
330
uint32 maxPacketSize;
332
/* Transport session context. */
333
HgfsTransportSessionInfo *transportSession;
335
/* Current state of the session. */
336
HgfsSessionInfoState state;
306
338
/* Lock to ensure some fileIO requests are atomic for a handle. */
307
339
MXUserExclLock *fileIOLock;
341
int numInvalidationAttempts;
309
343
Atomic_uint32 refCount; /* Reference count for session. */
359
393
uint32 numberOfCapabilities;
361
395
Bool activeNotification;
363
396
} HgfsSessionInfo;
399
* This represents the maximum number of HGFS sessions that can be
400
* created in a HGFS transport session. We picked a random value
401
* for this variable. There is no specific reason behind picking
404
#define MAX_SESSION_COUNT 1024
407
* This represents the maximum number attempts made by the HGFS
408
* invalidator before completely destroying the HGFS session. We
409
* picked a random value and there is no specific reason behind
410
* the value 4 for thie variable.
412
#define MAX_SESSION_INVALIDATION_ATTEMPTS 4
367
415
* These structs represent information about file open requests, file
563
612
HgfsSessionInfo *session, // IN: Session info
564
613
HgfsHandle *handle); // OUT: Search handle
615
/* Allocate/Add sessions helper functions. */
617
Bool HgfsServerAllocateSession(HgfsTransportSessionInfo *transportSession,
618
uint32 channelCapabilities,
619
HgfsSessionInfo **sessionData);
621
void HgfsServerSessionGet(HgfsSessionInfo *session);
623
HgfsInternalStatus HgfsServerTransportAddSessionToList(HgfsTransportSessionInfo *transportSession,
624
HgfsSessionInfo *sessionInfo);
567
626
/* Unpack/pack requests/reply helper functions. */
570
629
HgfsParseRequest(HgfsPacket *packet, // IN: request packet
571
HgfsSessionInfo *session, // IN: current session
630
HgfsTransportSessionInfo *transportSession, // IN: current session
572
631
HgfsInputParam **input, // OUT: request parameters
573
632
HgfsInternalStatus *status); // OUT: error code
1032
1091
size_t packetOutLen, // IN: Output packet size
1033
1092
HgfsInternalStatus status, // IN: status
1034
1093
HgfsHandle id, // IN: id of the request packet
1035
HgfsSessionInfo *session, // IN: session info
1094
HgfsTransportSessionInfo *transportSession, // IN: session info
1036
1095
HgfsSendFlags flags); // IN: flags how to send
1097
/* Get the session with a specific session id */
1099
HgfsServerTransportGetSessionInfo(HgfsTransportSessionInfo *transportSession, // IN: transport session info
1100
uint64 sessionId); // IN: session id
1039
1103
HgfsPacketSend(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1040
1104
char *packetOut, // IN: Output packet buffer
1041
1105
size_t packetOutLen, // IN: Output packet size
1042
HgfsSessionInfo *session, // IN: session info
1106
HgfsTransportSessionInfo *transportSession, // IN: session info
1043
1107
HgfsSendFlags flags); // IN: flags how to send
1163
1227
HgfsSessionInfo *session, // IN: Session info
1164
1228
HgfsLocalId *localId, // OUT: Local unique file ID
1165
1229
fileDesc *newHandle); // OUT: Handle to the file
1166
void HgfsServerSessionGet(HgfsSessionInfo *session); // IN: session context
1169
1231
HSPU_GetBuf(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1170
1232
uint32 startIndex, // IN: start index of iov
1172
1234
size_t bufSize, // IN: Size of buffer
1173
1235
Bool *isAllocated, // OUT: Was buffer allocated ?
1174
1236
MappingType mappingType, // IN: Readable/ Writeable ?
1175
HgfsSessionInfo *session); // IN: Session Info
1237
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1178
1240
HSPU_GetMetaPacket(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1179
1241
size_t *metaPacketSize, // OUT: Size of metaPacket
1180
HgfsSessionInfo *session); // IN: Session Info
1242
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1183
1245
HSPU_GetDataPacketBuf(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1184
1246
MappingType mappingType, // IN: Readable/ Writeable ?
1185
HgfsSessionInfo *session); // IN: Session Info
1247
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1188
1250
HSPU_PutPacket(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1189
HgfsSessionInfo *session); // IN: Session Info
1251
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1192
1254
HSPU_PutBuf(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1195
1257
size_t *bufSize, // IN: Size of the buffer
1196
1258
Bool *isAllocated, // IN: Was buffer allocated ?
1197
1259
MappingType mappingType, // IN: Readable/ Writeable ?
1198
HgfsSessionInfo *session); // IN: Session info
1260
HgfsTransportSessionInfo *transportSession); // IN: Session info
1201
1263
HSPU_PutDataPacketBuf(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1202
HgfsSessionInfo *session); // IN: Session Info
1264
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1205
1267
HSPU_PutMetaPacket(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1206
HgfsSessionInfo *session); // IN: Session Info
1268
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1209
1271
HSPU_CopyBufToDataIovec(HgfsPacket *packet, // IN/OUT: Hgfs packet
1210
1272
void *buf, // IN: Buffer to copy from
1211
1273
uint32 bufSize, // IN: Size of buffer
1212
HgfsSessionInfo *session);// IN: Session Info
1274
HgfsTransportSessionInfo *transportSession);// IN: Session Info
1214
1276
HSPU_CopyBufToIovec(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1215
1277
uint32 startIndex, // IN: start index into iov
1216
1278
void *buf, // IN: Buffer
1217
1279
size_t bufSize, // IN: Size of buffer
1218
HgfsSessionInfo *session); // IN: Session Info
1280
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1220
1282
HSPU_GetReplyPacket(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1221
1283
size_t *replyPacketSize, //IN/OUT: Size of reply Packet
1222
HgfsSessionInfo *session); // IN: Session Info
1284
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1225
1287
HSPU_PutReplyPacket(HgfsPacket *packet, // IN/OUT: Hgfs Packet
1226
HgfsSessionInfo *session); // IN: Session Info
1288
HgfsTransportSessionInfo *transportSession); // IN: Session Info
1227
1289
#endif /* __HGFS_SERVER_INT_H__ */