9 * Initialize the priv_sock system, by opening the communications sockets.
12 * p_sess - the current session object
14 void priv_sock_init(struct vsf_session
* p_sess
);
18 * Closes any open file descriptors relating to the priv_sock system.
21 * p_sess - the current session object
23 void priv_sock_close(struct vsf_session
* p_sess
);
25 /* priv_sock_set_parent_context()
27 * Closes the child's fd, e.g. p_sess->child_fd.
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()
36 * Closes the parent's fd, e.g. p_sess->parent_fd.
39 * p_sess - the current session object
41 void priv_sock_set_child_context(struct vsf_session
* p_sess
);
43 /* priv_sock_send_cmd()
45 * Sends a command, typically to the privileged side of the channel.
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()
54 * Sends a string to the other side of the channel.
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()
63 * Sends a buffer to the other side of the channel. The protocol used is the
64 * same as priv_sock_send_str()
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()
74 * Receives a buffer from the other side of the channel. The protocol used is
75 * the same as priv_sock_recv_str()
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()
85 * Receives a response, typically from the privileged side of the channel.
87 * fd - the fd on which to receive the response
91 char priv_sock_get_result(int fd
);
93 /* priv_sock_get_cmd()
95 * Receives a command, typically on the privileged side of the channel.
97 * fd - the fd on which to receive the command.
99 * The command that was sent.
101 char priv_sock_get_cmd(int fd
);
103 /* priv_sock_get_str()
105 * Receives a string from the other side of the channel.
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()
114 * Sends a command result, typically to the unprivileged side of the channel.
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()
123 * Sends a file descriptor to the other side of the channel.
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()
132 * Receives a file descriptor from the other side of the channel.
134 * fd - the fd on which to receive the descriptor
136 * The received file descriptor
138 int priv_sock_recv_fd(int fd
);
140 /* priv_sock_send_int()
142 * Sends an integer to the other side of the channel.
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()
151 * Receives an integer from the other side of the channel.
153 * fd - the fd on which to receive the integer
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 */