1BBFTP protocol version 1
2------------------------
3
4This protocol is available starting with bbftp version 1.9.0 and will be supported
5by all version 1.9.x and 2.x.x. It describe the message handling and the structures
6used for the message exchange.
7
8
9Connection and Login
10--------------------
11
12
13Client Side                                                       Server Side
14
15                                        connection
16                                 --------------------->
17Wait for MSG_CRYPT and                                      Generate RSA key
18a known crypt type. In case
19of error the control connection
20has to be closed
21                                        MSG_CRYPT
22                                 <----------------------
23
24Use the RSA pub key to encrypt                              Wait for MSG_LOG. All errors
25username and password.                                      generate the death of the process
26Send MSG_LOG plus the
27encrypted username and password.
28                                        MSG_LOG
29                                  --------------------->
30
31Wait for MSG_BAD, MSG_BAD_NO_RETRY                          Check username and password.
32or MSG_OK. In case of error the                             All errors generate the death
33control connection has to be closed                         of the process.
34                                        MSG_OK
35                                 <----------------------
36                                MSG_BAD MSG_BAD_NO_RETRY
37
38If MSG_OK can start command                                 if MSG_OK set the state to
39else retry connection.                                      S_LOGGED.
40
41
42
43The S_LOGGED State
44-------------------
45
46In this state the server is expecting the following messages.
47
48    MSG_STORE
49    MSG_STORE_C
50    MSG_RETR
51	MSG_RETR_C
52	MSG_RETR_RFIO
53	MSG_RETR_RFIO_C
54	MSG_MKDIR
55	MSG_CHDIR
56	MSG_LIST
57
58Within all version 1.9.X the server only reads eight bytes to know the message type
59and generate a MSG_BAD answer. After that it reads the following eight bytes ... etc,
60etc and that can lead to a stupid behaviour. (No new command can be implemented...)
61So starting with version 2.0.0 the server is going to read all the datas and generate
62a MSG_BAD_NO_RETRY. That allow further command to be accepted.
63
64
65The MSG_STORE and MSG_STORE_C message
66-------------------------------------
67
68	   Client Side                                                       Server Side
69
70Do checking. Get the sockets.
71Start the children.
72                                       MSG_STORE
73                                  --------------------->
74									  MSG_STORE_C
75Wait for MSG_BAD,BAD_NO_RETRY								Get the message and read it.
76or MSG_OK. Any other message								In case of error break the
77lead to the break of the control 							connection.
78connection.													Do some checks, if they fail return
79The children are waiting for a								MSG_BAD or MSB_BAD_NO_RETRY
80connection.
81															Fork all children and start them.
82
83															set the state to S_RECEIVING.
84
85															In case of error send MSG_BAD or
86															MSB_BAD_NO_RETRY.
87
88															Any message received during this
89															phase interrupt the transfer and
90															the control connection is closed.
91                                        MSG_OK
92                                 <----------------------
93                                MSG_BAD MSG_BAD_NO_RETRY
94
95
96The difference between MSG_STORE and MSG_STORE_C is that all data send by the children
97are starting with a header in MSG_STORE_C.
98
99The MSG_RETR and all related
100----------------------------
101
102	   Client Side                                                       Server Side
103
104Do checking. Get the data sokets.
105                                       MSG_RETR
106                                  --------------------->
107
108
109Wait for MSG_RETR_OK,  								   		Get the message and read it.
110MSG_BAD or MSG_BAD_NO_RETRY. Any							In case of error break the
111other message will lead to break							connection.
112the control connection. 									Do some checks, if they fail return
113															MSG_BAD or MSB_BAD_NO_RETRY
114
115															Send MSG_RETR_OK
116                                     MSG_RETR_OK
117                                 <----------------------
118								 MSG_BAD MSG_BAD_NO_RETRY
119
120If the file length is zero 			 					    Wait for MSG_RETR_START,
121then							 						  	MSG_ABR or MSG_CREATE_ZERO.
122   if creation is successfull
123      send MSG_CREATE_ZERO									Any other message will
124   else 													break the control connection
125      send MSG_ABORT
126else
127   do checking. Get the sockets.
128   Start the children.
129   In case of error send a
130   MSG_ABR.
131
132                                    MSG_RETR_START
133                                  --------------------->
134								 MSG_CREATE_ZERO MSG_ABR
135
136Wait for MSG_BAD,BAD_NO_RETRY								Fork all children and start them.
137,MSG_OK.
138Any other message lead to the 								set the state to S_RECEIVING.
139break of the control connection.
140The children are waiting for a								In case of error send MSG_BAD or
141connection.													MSB_BAD_NO_RETRY.
142
143															Any message except MSG_ABR
144															received during this phase
145															interrupt the transfer and
146															the control connection is closed.
147                                        MSG_OK
148                                 <----------------------
149                                MSG_BAD MSG_BAD_NO_RETRY
150
151
152
153
154The MSG_MKDIR message
155---------------------
156
157Do checking.
158                                       MSG_MKDIR
159                                  --------------------->
160
161Wait for MSG_BAD, MSG_BAD_NO_RETRY							Get the message and read it.
162or MSG_OK. Any other message will 							In case of error break the
163lead to break the control connection.						connection.
164 									 						Create the directory
165                                        MSG_OK
166                                 <----------------------
167                                MSG_BAD MSG_BAD_NO_RETRY
168
169
170
171
172The MSG_CHDIR message
173---------------------
174
175Do checking.
176                                       MSG_CHDIR
177                                  --------------------->
178
179Wait for MSG_BAD, MSG_BAD_NO_RETRY	    				    Get the message and read it.
180or MSG_OK. Any other message will 						    In case of error break the
181lead to break the control connection    				    connection.
182 									 					    Change to directory
183                                        MSG_OK
184                                 <----------------------
185                                MSG_BAD MSG_BAD_NO_RETRY
186
187
188The MSG_LIST message
189---------------------
190
191Do checking.
192                                       MSG_LIST
193                                  --------------------->
194
195Wait for MSG_BAD, MSG_BAD_NO_RETRY	    				    Get the message and read it.
196or MSG_LIST_REPL. Any other message will 					In case of error break the
197lead to break the control connection    				    connection.
198 									 					    Get the file list and send it
199															back
200                                      MSG_LIST_REPL
201                                 <----------------------
202                                MSG_BAD MSG_BAD_NO_RETRY
203
204
205