xref: /netbsd-src/usr.sbin/puffs/mount_psshfs/sftp_proto.h (revision f8326bf98ef8db583b1b30943f8cedd47fa4a2f0)
1*f8326bf9Spooka /*	$NetBSD: sftp_proto.h,v 1.2 2007/06/06 01:55:03 pooka Exp $	*/
2c3ef8ea5Spooka 
3c3ef8ea5Spooka /*
4c3ef8ea5Spooka  * Copyright (c) 2006  Antti Kantee.  All Rights Reserved.
5c3ef8ea5Spooka  *
6c3ef8ea5Spooka  * Redistribution and use in source and binary forms, with or without
7c3ef8ea5Spooka  * modification, are permitted provided that the following conditions
8c3ef8ea5Spooka  * are met:
9c3ef8ea5Spooka  * 1. Redistributions of source code must retain the above copyright
10c3ef8ea5Spooka  *    notice, this list of conditions and the following disclaimer.
11c3ef8ea5Spooka  * 2. Redistributions in binary form must reproduce the above copyright
12c3ef8ea5Spooka  *    notice, this list of conditions and the following disclaimer in the
13c3ef8ea5Spooka  *    documentation and/or other materials provided with the distribution.
14c3ef8ea5Spooka  *
15c3ef8ea5Spooka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16c3ef8ea5Spooka  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17c3ef8ea5Spooka  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18c3ef8ea5Spooka  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19c3ef8ea5Spooka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20c3ef8ea5Spooka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21c3ef8ea5Spooka  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22c3ef8ea5Spooka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23c3ef8ea5Spooka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24c3ef8ea5Spooka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25c3ef8ea5Spooka  * SUCH DAMAGE.
26c3ef8ea5Spooka  */
27c3ef8ea5Spooka 
28c3ef8ea5Spooka /*
29c3ef8ea5Spooka  * copypaste from draft-ietf-secsh-filexfer-03.txt
30c3ef8ea5Spooka  *
31c3ef8ea5Spooka  * XXX: we only implement protocol version 03.  We should *definitely*
32c3ef8ea5Spooka  * support a later version, since it maps to the vnode interface much
33c3ef8ea5Spooka  * better.  the problem is that most sftp servers only implement v3
34c3ef8ea5Spooka  * and I don't currently have the energy to deal with compat-fuddling
35c3ef8ea5Spooka  * in the code.
36c3ef8ea5Spooka  */
37c3ef8ea5Spooka 
38c3ef8ea5Spooka #ifndef PSSHFS_SFTPPROTO_H_
39c3ef8ea5Spooka #define PSSHFS_SFTPPROTO_H_
40c3ef8ea5Spooka 
41c3ef8ea5Spooka /* 3 General Packet Format */
42c3ef8ea5Spooka 
43c3ef8ea5Spooka #define SSH_FXP_INIT		1
44c3ef8ea5Spooka #define SSH_FXP_VERSION		2
45c3ef8ea5Spooka #define SSH_FXP_OPEN		3
46c3ef8ea5Spooka #define SSH_FXP_CLOSE		4
47c3ef8ea5Spooka #define SSH_FXP_READ		5
48c3ef8ea5Spooka #define SSH_FXP_WRITE		6
49c3ef8ea5Spooka #define SSH_FXP_LSTAT		7
50c3ef8ea5Spooka #define SSH_FXP_FSTAT		8
51c3ef8ea5Spooka #define SSH_FXP_SETSTAT		9
52c3ef8ea5Spooka #define SSH_FXP_FSETSTAT	10
53c3ef8ea5Spooka #define SSH_FXP_OPENDIR		11
54c3ef8ea5Spooka #define SSH_FXP_READDIR		12
55c3ef8ea5Spooka #define SSH_FXP_REMOVE		13
56c3ef8ea5Spooka #define SSH_FXP_MKDIR		14
57c3ef8ea5Spooka #define SSH_FXP_RMDIR		15
58c3ef8ea5Spooka #define SSH_FXP_REALPATH	16
59c3ef8ea5Spooka #define SSH_FXP_STAT		17
60c3ef8ea5Spooka #define SSH_FXP_RENAME		18
61c3ef8ea5Spooka #define SSH_FXP_READLINK	19
62c3ef8ea5Spooka #define SSH_FXP_SYMLINK		20
63c3ef8ea5Spooka 
64c3ef8ea5Spooka #define SSH_FXP_STATUS		101
65c3ef8ea5Spooka #define SSH_FXP_HANDLE		102
66c3ef8ea5Spooka #define SSH_FXP_DATA		103
67c3ef8ea5Spooka #define SSH_FXP_NAME		104
68c3ef8ea5Spooka #define SSH_FXP_ATTRS		105
69c3ef8ea5Spooka 
70c3ef8ea5Spooka #define SSH_FXP_EXTENDED	200
71c3ef8ea5Spooka #define SSH_FXP_EXTENDED_REPLY	201
72c3ef8ea5Spooka 
73c3ef8ea5Spooka /* 5.1 Flags */
74c3ef8ea5Spooka 
75c3ef8ea5Spooka /* XXX: UIDGID is obsoleted *AND NOT VALID* for version 3 of the protocol */
76c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_SIZE		0x00000001
77c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_UIDGID	0x00000002
78c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_PERMISSIONS	0x00000004
79c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_ACCESSTIME	0x00000008
80c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_CREATETIME	0x00000010
81c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_MODIFYTIME	0x00000020
82c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_ACL		0x00000040
83c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_OWNERGROUP	0x00000080
84c3ef8ea5Spooka #define SSH_FILEXFER_ATTR_EXTENDED	0x80000000
85c3ef8ea5Spooka 
86c3ef8ea5Spooka /* 5.2 Type */
87c3ef8ea5Spooka 
88c3ef8ea5Spooka #define SSH_FILEXFER_TYPE_REGULAR	1
89c3ef8ea5Spooka #define SSH_FILEXFER_TYPE_DIRECTORY	2
90c3ef8ea5Spooka #define SSH_FILEXFER_TYPE_SYMLINK	3
91c3ef8ea5Spooka #define SSH_FILEXFER_TYPE_SPECIAL	4
92c3ef8ea5Spooka #define SSH_FILEXFER_TYPE_UNKNOWN	5
93c3ef8ea5Spooka 
94c3ef8ea5Spooka 
95c3ef8ea5Spooka /* 6.3 Opening, Creating, and Closing Files */
96c3ef8ea5Spooka 
97c3ef8ea5Spooka #define SSH_FXF_READ	0x00000001
98c3ef8ea5Spooka #define SSH_FXF_WRITE	0x00000002
99c3ef8ea5Spooka #define SSH_FXF_APPEND	0x00000004
100c3ef8ea5Spooka #define SSH_FXF_CREAT	0x00000008
101c3ef8ea5Spooka #define SSH_FXF_TRUNC	0x00000010
102c3ef8ea5Spooka #define SSH_FXF_EXCL	0x00000020
103c3ef8ea5Spooka #define SSH_FXF_TEXT	0x00000040
104c3ef8ea5Spooka 
105c3ef8ea5Spooka 
106c3ef8ea5Spooka /* 7. Responses from the Server to the Client */
107c3ef8ea5Spooka 
108c3ef8ea5Spooka #define SSH_FX_OK			0
109c3ef8ea5Spooka #define SSH_FX_EOF			1
110c3ef8ea5Spooka #define SSH_FX_NO_SUCH_FILE		2
111c3ef8ea5Spooka #define SSH_FX_PERMISSION_DENIED	3
112c3ef8ea5Spooka #define SSH_FX_FAILURE			4
113c3ef8ea5Spooka #define SSH_FX_BAD_MESSAGE		5
114c3ef8ea5Spooka #define SSH_FX_NO_CONNECTION		6
115c3ef8ea5Spooka #define SSH_FX_CONNECTION_LOST		7
116c3ef8ea5Spooka #define SSH_FX_OP_UNSUPPORTED		8
117c3ef8ea5Spooka #define SSH_FX_INVALID_HANDLE		9
118c3ef8ea5Spooka #define SSH_FX_NO_SUCH_PATH		10
119c3ef8ea5Spooka #define SSH_FX_FILE_ALREADY_EXISTS	11
120c3ef8ea5Spooka #define SSH_FX_WRITE_PROTECT		12
121c3ef8ea5Spooka 
122c3ef8ea5Spooka #endif /* PSSHFS_SFTPPROTO_H_ */
123