usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / vsftpd / privsock.h
blob68ad07d8f775d60b2725be31ef964b309bd9f36e
1 #ifndef VSF_PRIVSOCK_H
2 #define VSF_PRIVSOCK_H
4 struct mystr;
5 struct vsf_session;
7 /* priv_sock_init()
8 * PURPOSE
9 * Initialize the priv_sock system, by opening the communications sockets.
11 * PARAMETERS
12 * p_sess - the current session object
14 void priv_sock_init(struct vsf_session* p_sess);
16 /* priv_sock_close()
17 * PURPOSE
18 * Closes any open file descriptors relating to the priv_sock system.
20 * PARAMETERS
21 * p_sess - the current session object
23 void priv_sock_close(struct vsf_session* p_sess);
25 /* priv_sock_set_parent_context()
26 * PURPOSE
27 * Closes the child's fd, e.g. p_sess->child_fd.
29 * PARAMETERS
30 * p_sess - the current session object
32 void priv_sock_set_parent_context(struct vsf_session* p_sess);
34 /* priv_sock_set_child_context()
35 * PURPOSE
36 * Closes the parent's fd, e.g. p_sess->parent_fd.
38 * PARAMETERS
39 * p_sess - the current session object
41 void priv_sock_set_child_context(struct vsf_session* p_sess);
43 /* priv_sock_send_cmd()
44 * PURPOSE
45 * Sends a command, typically to the privileged side of the channel.
46 * PARAMETERS
47 * fd - the fd on which to send the command
48 * cmd - the command to send
50 void priv_sock_send_cmd(int fd, char cmd);
52 /* priv_sock_send_str()
53 * PURPOSE
54 * Sends a string to the other side of the channel.
55 * PARAMETERS
56 * fd - the fd on which to send the string
57 * p_str - the string to send
59 void priv_sock_send_str(int fd, const struct mystr* p_str);
61 /* priv_sock_send_buf()
62 * PURPOSE
63 * Sends a buffer to the other side of the channel. The protocol used is the
64 * same as priv_sock_send_str()
65 * PARAMETERS
66 * fd - the fd on which to send the buffer
67 * p_buf - the buffer to send
68 * len - length of the buffer
70 void priv_sock_send_buf(int fd, const char* p_buf, unsigned int len);
72 /* priv_sock_recv_buf()
73 * PURPOSE
74 * Receives a buffer from the other side of the channel. The protocol used is
75 * the same as priv_sock_recv_str()
76 * PARAMETERS
77 * fd - the fd on which to receive the buffer
78 * p_buf - the buffer to write into
79 * len - length of the buffer
81 void priv_sock_recv_buf(int fd, char* p_buf, unsigned int len);
83 /* priv_sock_get_result()
84 * PURPOSE
85 * Receives a response, typically from the privileged side of the channel.
86 * PARAMETERS
87 * fd - the fd on which to receive the response
88 * RETURNS
89 * The response code.
91 char priv_sock_get_result(int fd);
93 /* priv_sock_get_cmd()
94 * PURPOSE
95 * Receives a command, typically on the privileged side of the channel.
96 * PARAMETERS
97 * fd - the fd on which to receive the command.
98 * RETURNS
99 * The command that was sent.
101 char priv_sock_get_cmd(int fd);
103 /* priv_sock_get_str()
104 * PURPOSE
105 * Receives a string from the other side of the channel.
106 * PARAMETERS
107 * fd - the fd on which to receive the string
108 * p_dest - where to copy the received string
110 void priv_sock_get_str(int fd, struct mystr* p_dest);
112 /* priv_sock_send_result()
113 * PURPOSE
114 * Sends a command result, typically to the unprivileged side of the channel.
115 * PARAMETERS
116 * fd - the fd on which to send the result
117 * res - the result to send
119 void priv_sock_send_result(int fd, char res);
121 /* priv_sock_send_fd()
122 * PURPOSE
123 * Sends a file descriptor to the other side of the channel.
124 * PARAMETERS
125 * fd - the fd on which to send the descriptor
126 * send_fd - the descriptor to send
128 void priv_sock_send_fd(int fd, int send_fd);
130 /* priv_sock_recv_fd()
131 * PURPOSE
132 * Receives a file descriptor from the other side of the channel.
133 * PARAMETERS
134 * fd - the fd on which to receive the descriptor
135 * RETURNS
136 * The received file descriptor
138 int priv_sock_recv_fd(int fd);
140 /* priv_sock_send_int()
141 * PURPOSE
142 * Sends an integer to the other side of the channel.
143 * PARAMETERS
144 * fd - the fd on which to send the integer
145 * the_int - the integer to send
147 void priv_sock_send_int(int fd, int the_int);
149 /* priv_sock_get_int()
150 * PURPOSE
151 * Receives an integer from the other side of the channel.
152 * PARAMETERS
153 * fd - the fd on which to receive the integer
154 * RETURNS
155 * The integer that was sent.
157 int priv_sock_get_int(int fd);
159 #define PRIV_SOCK_LOGIN 1
160 #define PRIV_SOCK_CHOWN 2
161 #define PRIV_SOCK_GET_DATA_SOCK 3
162 #define PRIV_SOCK_GET_USER_CMD 4
163 #define PRIV_SOCK_WRITE_USER_RESP 5
164 #define PRIV_SOCK_DO_SSL_HANDSHAKE 6
165 #define PRIV_SOCK_DO_SSL_CLOSE 7
166 #define PRIV_SOCK_DO_SSL_READ 8
167 #define PRIV_SOCK_DO_SSL_WRITE 9
168 #define PRIV_SOCK_PASV_CLEANUP 10
169 #define PRIV_SOCK_PASV_ACTIVE 11
170 #define PRIV_SOCK_PASV_LISTEN 12
171 #define PRIV_SOCK_PASV_ACCEPT 13
173 #define PRIV_SOCK_RESULT_OK 1
174 #define PRIV_SOCK_RESULT_BAD 2
176 #endif /* VSF_PRIVSOCK_H */