5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2001 - 2005 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
23 /****h* silcsftp/SILC SFTP Interface
27 * SILC SFTP Interface is the implementation of the Secure File Transfer
28 * Protocol. The interface defines the SFTP client and the SFTP server.
29 * The SFTP is the mandatory file transfer protocol in the SILC protocol.
30 * The SFTP server implementation is filesystem independent and generic
31 * interface is defined to represent filesystem access.
33 * The SilcSFTP context is the actual SFTP client or SFTP server, and
34 * each SFTP session (associated to a socket connection) must create
39 /****s* silcsftp/SilcSFTPAPI/SilcSFTP
43 * typedef struct SilcSFTPStruct *SilcSFTP;
47 * This context is the actual SFTP client and SFTP server, and is
48 * allocated by silc_sftp_client_start or silc_sftp_server_start and
49 * given as argument usually to all silc_sftp_* functions. It is freed
50 * by the silc_sftp_client_shutdown or silc_sftp_server_shutdown
54 typedef struct SilcSFTPStruct *SilcSFTP;
56 /****d* silcsftp/SilcSFTPAPI/SilcSFTPVersion
60 * typedef SilcUInt32 SilcSFTPVersion;
68 typedef SilcUInt32 SilcSFTPVersion;
71 /* SFTP protocol version */
72 #define SILC_SFTP_PROTOCOL_VERSION 3
74 /****d* silcsftp/SilcSFTPAPI/SilcSFTPStatus
78 * typedef enum { ... } SilcSFTPStatus
82 * SFTP protocol status types. These enumerations is used to indicate
83 * the status of request. The server can send these to the client when
84 * client has requested an operation.
89 SILC_SFTP_STATUS_OK = 0, /* Operation successful */
90 SILC_SFTP_STATUS_EOF = 1, /* No more data available */
91 SILC_SFTP_STATUS_NO_SUCH_FILE = 2, /* File does not exist */
92 SILC_SFTP_STATUS_PERMISSION_DENIED = 3, /* No sufficient permissions */
93 SILC_SFTP_STATUS_FAILURE = 4, /* Operation failed */
94 SILC_SFTP_STATUS_BAD_MESSAGE = 5, /* Bad message received */
95 SILC_SFTP_STATUS_NO_CONNECTION = 6, /* No connection to server */
96 SILC_SFTP_STATUS_CONNECTION_LOST = 7, /* Connection lost to server */
97 SILC_SFTP_STATUS_OP_UNSUPPORTED = 8, /* Operation unsupported */
98 SILC_SFTP_STATUS_INVALID_HANDLE = 9, /* Invalid file handle */
99 SILC_SFTP_STATUS_NO_SUCH_PATH = 10, /* Path does not exist */
100 SILC_SFTP_STATUS_FILE_ALREADY_EXIST = 11, /* File already exists */
101 SILC_SFTP_STATUS_WRITE_PROTECT = 12, /* Read-only or protected */
102 SILC_SFTP_STATUS_NO_MEDIA = 13, /* No media available */
103 SILC_SFTP_STATUS_NO_SPACE_ON_DEVICE = 14, /* No space on device */
104 SILC_SFTP_STATUS_QUOTA_EXCEEDED = 15, /* Quota limit reached */
105 SILC_SFTP_STATUS_UNKNOWN_PRINCIBLE = 16, /* Unknown princible */
106 SILC_SFTP_STATUS_LOCK_CONFLICT = 17, /* File already locked */
107 SILC_SFTP_STATUS_NOT_EMPTY = 18, /* Directory not empty */
108 SILC_SFTP_STATUS_NOT_A_DIRECTORY = 19, /* Not a directory */
109 SILC_SFTP_STATUS_INVALID_FILENAME = 20, /* Invalid filename */
110 SILC_SFTP_STATUS_LINK_LOOP = 21, /* Too many symlinks */
111 SILC_SFTP_STATUS_CANNOT_DELETE = 22, /* Could not delete file */
112 SILC_SFTP_STATUS_INVALID_PARAMETER = 23, /* Invalid parameter */
113 SILC_SFTP_STATUS_FILE_IS_A_DIRECTORY = 24, /* File is a directory file */
114 SILC_SFTP_STATUS_BR_LOCK_CONFLICT = 25, /* Byte range lock conflict */
115 SILC_SFTP_STATUS_BR_LOCK_REFUSED = 26, /* Byte range lock refused */
116 SILC_SFTP_STATUS_DELETE_PENDING = 27, /* File is being deleted */
117 SILC_SFTP_STATUS_FILE_CORRUPT = 28, /* File is corrupted */
121 /****d* silcsftp/SilcSFTPAPI/SilcSFTPFileOperation
125 * typedef enum { ... } SilcSFTPFileOperation
129 * SFTP protocol file operation flags. These enumerations can be used
130 * by the client when client is opening an file, to indicate how it
131 * would like to open the file.
136 SILC_SFTP_FXF_READ = 0x00000001, /* Reading */
137 SILC_SFTP_FXF_WRITE = 0x00000002, /* Writing */
138 SILC_SFTP_FXF_APPEND = 0x00000004, /* Appending to end of file */
139 SILC_SFTP_FXF_CREAT = 0x00000008, /* Create if doesn't exist */
140 SILC_SFTP_FXF_TRUNC = 0x00000010, /* Truncate if exists */
141 SILC_SFTP_FXF_EXCL = 0x00000020, /* Don't create if exists */
142 } SilcSFTPFileOperation;
145 /****s* silcsftp/SilcSFTPAPI/SilcSFTPAttributes
149 * typedef struct { ... } *SilcSFTPAttributes, SilcSFTPAttributesStruct;
153 * SFTP File attributes structure represents the attributes for a file.
154 * This structure can be used by the client to send attributes to the
155 * server, and by server to return file attributes to the client.
159 SilcUInt32 flags; /* Flags to indicate present attributes */
160 SilcUInt64 size; /* Sife of the file in bytes */
161 SilcUInt32 uid; /* Unix user ID */
162 SilcUInt32 gid; /* Unix group ID */
163 SilcUInt32 permissions; /* POSIX file permission bitmask */
164 SilcUInt32 atime; /* Access time of file */
165 SilcUInt32 mtime; /* Modification time of file */
167 SilcUInt32 extended_count; /* Extended type and data count */
168 SilcBuffer *extended_type;
169 SilcBuffer *extended_data;
170 } *SilcSFTPAttributes, SilcSFTPAttributesStruct;
172 /****s* silcsftp/SilcSFTPAPI/SilcSFTPName
176 * typedef struct { ... } *SilcSFTPName, SilcSFTPNameStruct
180 * SFTP Name structure represents the name reply received from the server.
181 * It includes the returned file(s) short and long file names and
182 * attributes for the file(s). This is returned by the server for
183 * example when reading the contents of a directory.
188 char **long_filename;
189 SilcSFTPAttributes *attrs;
190 SilcUInt32 count; /* Number of files */
191 } *SilcSFTPName, SilcSFTPNameStruct;
193 /****s* silcsftp/SilcSFTPAPI/SilcSFTPHandle
197 * typedef struct SilcSFTPHandleStruct *SilcSFTPHandle;
201 * This context represents an open file handle and is allocated by
202 * the library. The application receives this context in the
203 * SilcSFTPHandleCallback function.
206 typedef struct SilcSFTPHandleStruct *SilcSFTPHandle;
208 /****f* silcsftp/SilcSFTPAPI/SilcSFTPSendPacketCallback
212 * typedef void (*SilcSFTPSendPacketCallback)(SilcBuffer packet,
217 * Packet sending callback. The caller of this interface will provide this
218 * function for the library. The libary will call this function everytime
219 * it needs to send a packet to the remote host.
222 typedef void (*SilcSFTPSendPacketCallback)(SilcBuffer packet, void *context);
224 /****f* silcsftp/SilcSFTPAPI/SilcSFTPVersionCallback
228 * typedef void (*SilcSFTPVersionCallback)(SilcSFTP sftp,
229 * SilcSFTPStatus status,
230 * SilcSFTPVersion version,
235 * Version callback is called at the protocol initialization phase when
236 * the server returns the version of the protocol. The `version' indicates
237 * the version of the protocol.
240 typedef void (*SilcSFTPVersionCallback)(SilcSFTP sftp,
241 SilcSFTPStatus status,
242 SilcSFTPVersion version,
245 /****f* silcsftp/SilcSFTPAPI/SilcSFTPStatusCallback
249 * typedef void (*SilcSFTPStatusCallback)(SilcSFTP sftp,
250 * SilcSFTPStatus status,
251 * const char *message,
252 * const char *language_tag,
257 * Status callback is called every time server returns a status packet
258 * for a request the client has made. The `status' indicates the type
259 * of the status. The `message' is optional error message received from
260 * the server, in language indicated by the `language_tag'. Both of
261 * these pointers may be NULL.
264 typedef void (*SilcSFTPStatusCallback)(SilcSFTP sftp,
265 SilcSFTPStatus status,
267 const char *language_tag,
270 /****f* silcsftp/SilcSFTPAPI/SilcSFTPHandleCallback
274 * typedef void (*SilcSFTPHandleCallback)(SilcSFTP sftp,
275 * SilcSFTPStatus status,
276 * SilcSFTPHandle handle,
281 * Handle callback is called when the server returns a handle to the
282 * client as a result of some request client has made. The `handle'
283 * is the file handle and the application can use it to perform file
284 * operations for the handle. Each of the returned handle must be
285 * also closed at some point with silc_sftp_close.
288 typedef void (*SilcSFTPHandleCallback)(SilcSFTP sftp,
289 SilcSFTPStatus status,
290 SilcSFTPHandle handle,
293 /****f* silcsftp/SilcSFTPAPI/SilcSFTPDataCallback
297 * typedef void (*SilcSFTPDataCallback)(SilcSFTP sftp,
298 * SilcSFTPStatus status,
299 * const unsigned char *data,
300 * SilcUInt32 data_len,
305 * Data callback is called when data packet is received from the server.
306 * This is called for example when application is reading a file from
307 * the server. The `data' is the raw data of length of `data_len'.
310 typedef void (*SilcSFTPDataCallback)(SilcSFTP sftp,
311 SilcSFTPStatus status,
312 const unsigned char *data,
316 /****f* silcsftp/SilcSFTPAPI/SilcSFTPNameCallback
320 * typedef void (*SilcSFTPNameCallback)(SilcSFTP sftp,
321 * SilcSFTPStatus status,
322 * const SilcSFTPName name,
327 * Name callback is called when directory is being read by the client.
328 * The server returns one or more file names in one reply. These file
329 * names are saved in the `filename' structures with their short and
330 * long name format, and with file attributes.
333 typedef void (*SilcSFTPNameCallback)(SilcSFTP sftp,
334 SilcSFTPStatus status,
335 const SilcSFTPName name,
338 /****f* silcsftp/SilcSFTPAPI/SilcSFTPAttrCallback
342 * typedef void (*SilcSFTPAttrCallback)(SilcSFTP sftp,
343 * SilcSFTPStatus status,
344 * const SilcSFTPAttributes attrs,
349 * Attributes callback is called when the server returns the attributes
350 * for a file the client has requested. The attributes are saved in
351 * the `attrs' structure.
354 typedef void (*SilcSFTPAttrCallback)(SilcSFTP sftp,
355 SilcSFTPStatus status,
356 const SilcSFTPAttributes attrs,
359 /****f* silcsftp/SilcSFTPAPI/SilcSFTPExtendedCallback
363 * typedef void (*SilcSFTPExtendedCallback)(SilcSFTP sftp,
364 * SilcSFTPStatus status,
365 * const unsigned char *data,
366 * SilcUInt32 data_len,
371 * Extended request callback is called when client sends extended
372 * request to the server. The `data' is arbitrary data returned by the
373 * server and its encoding is the extended request specific.
376 typedef void (*SilcSFTPExtendedCallback)(SilcSFTP sftp,
377 SilcSFTPStatus status,
378 const unsigned char *data,
383 /* SFTP Client Interface */
385 /****f* silcsftp/SilcSFTPAPI/silc_sftp_client_start
389 * SilcSFTP silc_sftp_client_start(SilcStream stream,
390 * SilcSFTPVersionCallback callback,
395 * Starts SFTP client and returns context to it. The version callback
396 * indicated by the `callback' will be called after the SFTP session has
397 * been started and server has returned the version of the protocol. The
398 * SFTP client context is returned in the callback too. This returns the
399 * allocated SFTP client context or NULL on error. The `stream' will be
400 * used to read from and write to the SFTP packets.
403 SilcSFTP silc_sftp_client_start(SilcStream stream,
404 SilcSFTPVersionCallback callback,
407 /****f* silcsftp/SilcSFTPAPI/silc_sftp_client_shutdown
411 * void silc_sftp_client_shutdown(SilcSFTP sftp);
415 * Shutdown's the SFTP client. The caller is responsible of closing
416 * the associated socket connection. The SFTP context is freed and is
417 * invalid after this function returns.
420 void silc_sftp_client_shutdown(SilcSFTP sftp);
422 /****f* silcsftp/SilcSFTPAPI/silc_sftp_open
426 * void silc_sftp_open(SilcSFTP sftp,
427 * const char *filename,
428 * SilcSFTPFileOperation pflags,
429 * SilcSFTPAttributes attrs,
430 * SilcSFTPHandleCallback callback,
435 * Open a file indicated by the `filename' with flags indicated by the
436 * `pflags', and with attributes indicated by the `attsr'. Calls the
437 * `callback' to return the opened file handle.
440 void silc_sftp_open(SilcSFTP sftp,
441 const char *filename,
442 SilcSFTPFileOperation pflags,
443 SilcSFTPAttributes attrs,
444 SilcSFTPHandleCallback callback,
447 /****f* silcsftp/SilcSFTPAPI/silc_sftp_close
451 * void silc_sftp_close(SilcSFTP sftp,
452 * SilcSFTPHandle handle,
453 * SilcSFTPStatusCallback callback,
458 * Closes the file indicated by the file handle `handle'. Calls the
459 * `callback' to indicate the status of the closing.
462 void silc_sftp_close(SilcSFTP sftp,
463 SilcSFTPHandle handle,
464 SilcSFTPStatusCallback callback,
467 /****f* silcsftp/SilcSFTPAPI/silc_sftp_read
471 * void silc_sftp_read(SilcSFTP sftp,
472 * SilcSFTPHandle handle,
475 * SilcSFTPDataCallback callback,
480 * Reads data from the file indicated by the file handle `handle' starting
481 * from the offset of `offset' at most `len' bytes. The `callback' is
482 * called to return the read data.
485 void silc_sftp_read(SilcSFTP sftp,
486 SilcSFTPHandle handle,
489 SilcSFTPDataCallback callback,
492 /****f* silcsftp/SilcSFTPAPI/silc_sftp_write
496 * void silc_sftp_write(SilcSFTP sftp,
497 * SilcSFTPHandle handle,
499 * const unsigned char *data,
500 * SilcUInt32 data_len,
501 * SilcSFTPStatusCallback callback,
506 * Writes to a file indicated by the file handle `handle' starting from
507 * offset of `offset' at most `data_len' bytes of `data'. The `callback'
508 * is called to indicate the status of the writing.
511 void silc_sftp_write(SilcSFTP sftp,
512 SilcSFTPHandle handle,
514 const unsigned char *data,
516 SilcSFTPStatusCallback callback,
519 /****f* silcsftp/SilcSFTPAPI/silc_sftp_remove
523 * void silc_sftp_remove(SilcSFTP sftp,
524 * const char *filename,
525 * SilcSFTPStatusCallback callback,
530 * Removes a file indicated by the `filename'. Calls the `callback'
531 * to indicate the status of the removing.
534 void silc_sftp_remove(SilcSFTP sftp,
535 const char *filename,
536 SilcSFTPStatusCallback callback,
539 /****f* silcsftp/SilcSFTPAPI/silc_sftp_rename
543 * void silc_sftp_rename(SilcSFTP sftp,
544 * const char *oldname,
545 * const char *newname,
546 * SilcSFTPStatusCallback callback,
551 * Renames a file indicated by the `oldname' to the name `newname'. The
552 * `callback' is called to indicate the status of the renaming.
555 void silc_sftp_rename(SilcSFTP sftp,
558 SilcSFTPStatusCallback callback,
561 /****f* silcsftp/SilcSFTPAPI/silc_sftp_mkdir
565 * void silc_sftp_mkdir(SilcSFTP sftp,
567 * SilcSFTPAttributes attrs,
568 * SilcSFTPStatusCallback callback,
573 * Creates a new directory indicated by the `path' with attributes indicated
574 * by the `attrs'. The `callback' is called to indicate the status of the
578 void silc_sftp_mkdir(SilcSFTP sftp,
580 SilcSFTPAttributes attrs,
581 SilcSFTPStatusCallback callback,
584 /****f* silcsftp/SilcSFTPAPI/silc_sftp_rmdir
588 * void silc_sftp_rmdir(SilcSFTP sftp,
590 * SilcSFTPStatusCallback callback,
595 * Removes a directory indicated by the `path' and calls the `callback'
596 * to indicate the status of the removal.
599 void silc_sftp_rmdir(SilcSFTP sftp,
601 SilcSFTPStatusCallback callback,
604 /****f* silcsftp/SilcSFTPAPI/silc_sftp_opendir
608 * void silc_sftp_opendir(SilcSFTP sftp,
610 * SilcSFTPHandleCallback callback,
615 * Opens a directory indicated by the `path'. The `callback' is called
616 * to return the opened file handle.
619 void silc_sftp_opendir(SilcSFTP sftp,
621 SilcSFTPHandleCallback callback,
624 /****f* silcsftp/SilcSFTPAPI/silc_sftp_readdir
628 * void silc_sftp_readdir(SilcSFTP sftp,
629 * SilcSFTPHandle handle,
630 * SilcSFTPNameCallback callback,
635 * Reads the contents of the directory indicated by the `handle' and
636 * calls the `callback' to return the read file(s) from the directory.
639 void silc_sftp_readdir(SilcSFTP sftp,
640 SilcSFTPHandle handle,
641 SilcSFTPNameCallback callback,
644 /****f* silcsftp/SilcSFTPAPI/silc_sftp_stat
648 * void silc_sftp_stat(SilcSFTP sftp,
650 * SilcSFTPAttrCallback callback,
655 * Gets the file attributes for a file indicated by the `path'. This
656 * will follow symbolic links also. Calls the `callback' to return the
660 void silc_sftp_stat(SilcSFTP sftp,
662 SilcSFTPAttrCallback callback,
665 /****f* silcsftp/SilcSFTPAPI/silc_sftp_lstat
669 * void silc_sftp_lstat(SilcSFTP sftp,
671 * SilcSFTPAttrCallback callback,
676 * Gets the file attributes for a file indicated by the `path'. This
677 * will not follow symbolic links. Calls the `callback' to return the
681 void silc_sftp_lstat(SilcSFTP sftp,
683 SilcSFTPAttrCallback callback,
686 /****f* silcsftp/SilcSFTPAPI/silc_sftp_fstat
690 * void silc_sftp_fstat(SilcSFTP fstp,
691 * SilcSFTPHandle handle,
692 * SilcSFTPAttrCallback callback,
697 * Gets a file attributes for a opened file indicated by the `handle'.
698 * Calls the `callback' to return the file attributes.
701 void silc_sftp_fstat(SilcSFTP fstp,
702 SilcSFTPHandle handle,
703 SilcSFTPAttrCallback callback,
706 /****f* silcsftp/SilcSFTPAPI/silc_sftp_setstat
710 * void silc_sftp_setstat(SilcSFTP sftp,
712 * SilcSFTPAttributes attrs,
713 * SilcSFTPStatusCallback callback,
718 * Sets a file attributes to a file indicated by the `path' with the
719 * attributes indicated by the `attrs'. Calls the `callback' to indicate
720 * the status of the setting.
723 void silc_sftp_setstat(SilcSFTP sftp,
725 SilcSFTPAttributes attrs,
726 SilcSFTPStatusCallback callback,
729 /****f* silcsftp/SilcSFTPAPI/silc_sftp_fsetstat
733 * void silc_sftp_fsetstat(SilcSFTP sftp,
734 * SilcSFTPHandle handle,
735 * SilcSFTPAttributes attrs,
736 * SilcSFTPStatusCallback callback,
741 * Sets a file attributes to a opened file indicated by the `handle' with
742 * the attributes indicated by the `attrs'. Calls the `callback' to
743 * indicate the status of the setting.
746 void silc_sftp_fsetstat(SilcSFTP sftp,
747 SilcSFTPHandle handle,
748 SilcSFTPAttributes attrs,
749 SilcSFTPStatusCallback callback,
752 /****f* silcsftp/SilcSFTPAPI/silc_sftp_readlink
756 * void silc_sftp_readlink(SilcSFTP sftp,
758 * SilcSFTPNameCallback callback,
763 * Reads the target of a symbolic link indicated by the `path'. The
764 * `callback' is called to return the target of the symbolic link.
767 void silc_sftp_readlink(SilcSFTP sftp,
769 SilcSFTPNameCallback callback,
772 /****f* silcsftp/SilcSFTPAPI/silc_sftp_symlink
776 * void silc_sftp_symlink(SilcSFTP sftp,
777 * const char *linkpath,
778 * const char *targetpath,
779 * SilcSFTPStatusCallback callback,
784 * Creates a new symbolic link indicated by the `linkpath' to the target
785 * indicated by the `targetpath'. The `callback' is called to indicate
786 * the status of creation.
789 void silc_sftp_symlink(SilcSFTP sftp,
790 const char *linkpath,
791 const char *targetpath,
792 SilcSFTPStatusCallback callback,
795 /****f* silcsftp/SilcSFTPAPI/silc_sftp_realpath
799 * void silc_sftp_realpath(SilcSFTP sftp,
801 * SilcSFTPNameCallback callback,
806 * Canonicalizes the path indicated by the `path' to a absolute path.
807 * The `callback' is called to return the absolute path.
810 void silc_sftp_realpath(SilcSFTP sftp,
812 SilcSFTPNameCallback callback,
815 /****f* silcsftp/SilcSFTPAPI/silc_sftp_extended
819 * void silc_sftp_extended(SilcSFTP sftp,
820 * const char *request,
821 * const unsigned char *data,
822 * SilcUInt32 data_len,
823 * SilcSFTPExtendedCallback callback,
828 * Performs an extended operation indicated by the `request' with
829 * optional extended operation data indicated by the `data'. The callback
830 * is called to return any data associated with the extended request.
833 void silc_sftp_extended(SilcSFTP sftp,
835 const unsigned char *data,
837 SilcSFTPExtendedCallback callback,
841 /* SFTP Server Interface */
843 #include "silcsftp_fs.h"
845 /****f* silcsftp/SilcSFTPAPI/silc_sftp_server_start
849 * SilcSFTP silc_sftp_server_start(SilcSFTPSendPacketCallback send_packet,
850 * void *send_context,
851 * SilcSFTPFilesystem fs);
855 * Starts SFTP server and returns a context to it. This function returns
856 * the allocated SFTP server context or NULL on error. The `send_packet'
857 * is called by the library when it needs to send a packet. The `fs' is the
858 * filesystem context allocated by the application. Each socket connection
859 * should start its own server by calling this function.
862 SilcSFTP silc_sftp_server_start(SilcSFTPSendPacketCallback send_packet,
864 SilcSFTPFilesystem fs);
866 /****f* silcsftp/SilcSFTPAPI/silc_sftp_server_shutdown
870 * void silc_sftp_server_shutdown(SilcSFTP sftp);
874 * Shutdown's the SFTP server. The caller is responsible of closing
875 * the associated socket connection. The SFTP context is freed and is
876 * invalid after this function returns.
879 void silc_sftp_server_shutdown(SilcSFTP sftp);
881 /****d* silcsftp/SilcSFTPAPI/SilcSFTPMonitors
885 * typedef enum { ... } SilcSFTPMonitors;
889 * SFTP server monitor types. These can be masked together to monitor
890 * various client requests.
895 SILC_SFTP_MONITOR_INIT = 0x0001,
896 SILC_SFTP_MONITOR_OPEN = 0x0002,
897 SILC_SFTP_MONITOR_CLOSE = 0x0004,
898 SILC_SFTP_MONITOR_READ = 0x0008,
899 SILC_SFTP_MONITOR_WRITE = 0x0010,
900 SILC_SFTP_MONITOR_REMOVE = 0x0020,
901 SILC_SFTP_MONITOR_RENAME = 0x0040,
902 SILC_SFTP_MONITOR_MKDIR = 0x0080,
903 SILC_SFTP_MONITOR_RMDIR = 0x0100,
904 SILC_SFTP_MONITOR_OPENDIR = 0x0200,
905 SILC_SFTP_MONITOR_READDIR = 0x0400,
906 SILC_SFTP_MONITOR_STAT = 0x0800,
907 SILC_SFTP_MONITOR_LSTAT = 0x1000,
908 SILC_SFTP_MONITOR_FSTAT = 0x2000,
909 SILC_SFTP_MONITOR_SETSTAT = 0x4000,
910 SILC_SFTP_MONITOR_FSETSTAT = 0x8000,
911 SILC_SFTP_MONITOR_READLINK = 0x10000,
912 SILC_SFTP_MONITOR_SYMLINK = 0x20000,
913 SILC_SFTP_MONITOR_REALPATH = 0x40000,
914 SILC_SFTP_MONITOR_EXTENDED = 0x80000,
918 /****s* silcsftp/SilcSFTPAPI/SilcSFTPMonitorData
922 * typedef struct { ... } *SilcSFTPMonitorData, SilcSFTPMonitorDataStruct;
926 * This structure includes the monitor type specific data. The
927 * application can check what the client has requested from this
933 SilcSFTPVersion version; /* _INIT */
934 char *name; /* _OPEN, _REMOVE, _RENAME, _MKDIR,
935 _RMDIR, _OPENDIR, _STAT, _LSTAT,
936 _SETSTAT, _READLINK, _SYMLINK, _REALPATH */
937 char *name2; /* _RENAME, _SYMLINK */
938 SilcSFTPFileOperation pflags; /* _OPEN */
939 SilcUInt64 offset; /* _READ, _WRITE */
940 SilcUInt32 data_len; /* _READ, _WRITE */
941 SilcSFTPName names; /* _READDIR, _READLINK, _REALPATH */
942 } *SilcSFTPMonitorData, SilcSFTPMonitorDataStruct;
945 /****f* silcsftp/SilcSFTPAPI/SilcSFTPMonitor
949 * typedef void (*SilcSFTPMonitor)(SilcSFTP sftp
950 * SilcSFTPMonitors type,
951 * const SilcSFTPMonitorData data,
956 * Monitor callback that is called when an specified request is
957 * received from client. The `type' is the requested type that
958 * was being monitored.
961 typedef void (*SilcSFTPMonitor)(SilcSFTP sftp,
962 SilcSFTPMonitors type,
963 const SilcSFTPMonitorData data,
966 /****f* silcsftp/SilcSFTPAPI/silc_sftp_server_set_monitor
970 * void silc_sftp_server_set_monitor(SilcSFTP sftp,
971 * SilcSFTPMonitors monitors,
972 * SilcSFTPMonitor monitor,
977 * Sets monitor callback to monitor various request sent by a client.
978 * When request that has been set in the `monitors' is received the
979 * monitor callback will be called to notify the caller.
982 void silc_sftp_server_set_monitor(SilcSFTP sftp,
983 SilcSFTPMonitors monitors,
984 SilcSFTPMonitor monitor,
987 #endif /* SILCSFTP_H */