http://code.google.com/p/ftpii/source/detail?r=308
Modified:
/branches/0.0.22/source/ftp.c
/branches/0.0.22/source/ftpii.c
/branches/0.0.22/source/net.c
=======================================
--- /branches/0.0.22/source/ftp.c Sun Aug 22 00:38:08 2010
+++ /branches/0.0.22/source/ftp.c Tue Aug 24 04:32:37 2010
@@ -278,7 +278,8 @@
struct sockaddr_in bindAddress;
memset(&bindAddress, 0, sizeof(bindAddress));
bindAddress.sin_family = AF_INET;
- bindAddress.sin_port = htons(passive_port++); // XXX: BUG: This will
overflow eventually, with interesting results...
+ if (passive_port < 1024) passive_port = 1024;
+ bindAddress.sin_port = htons(passive_port++);
bindAddress.sin_addr.s_addr = htonl(INADDR_ANY);
s32 result;
if ((result = net_bind(client->passive_socket, (struct sockaddr
*)&bindAddress, sizeof(bindAddress))) < 0) {
@@ -318,9 +319,9 @@
return write_reply(client, 200, "PORT command successful.");
}
-typedef s32 (*data_connection_handler)(client_t *client,
data_connection_callback callback, void *arg);
-
-static s32 prepare_data_connection_active(client_t *client,
data_connection_callback callback, void *arg) {
+typedef s32 (*data_connection_handler)(client_t *client);
+
+static s32 prepare_data_connection_active(client_t *client) {
s32 data_socket = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (data_socket < 0) return data_socket;
set_blocking(data_socket, false);
@@ -340,7 +341,7 @@
return 0;
}
-static s32 prepare_data_connection_passive(client_t *client,
data_connection_callback callback, void *arg) {
+static s32 prepare_data_connection_passive(client_t *client) {
client->data_socket = client->passive_socket;
printf("Waiting for data connections...\n");
return 0;
@@ -351,7 +352,7 @@
if (result >= 0) {
data_connection_handler handler = prepare_data_connection_active;
if (client->passive_socket >= 0) handler =
prepare_data_connection_passive;
- result = handler(client, (data_connection_callback)callback, arg);
+ result = handler(client);
if (result < 0) {
result = write_reply(client, 520, "Closing data connection,
error occurred during transfer.");
} else {
=======================================
--- /branches/0.0.22/source/ftpii.c Sun Aug 22 00:38:08 2010
+++ /branches/0.0.22/source/ftpii.c Tue Aug 24 04:32:37 2010
@@ -39,13 +39,13 @@
static void initialise_ftpii() {
DI_Init();
- IOSPATCH_Apply();
initialise_video();
+ IOSPATCH_Apply();
+ printf("ftpii 0.0.22 (IOS %i)\n", IOS_GetVersion());
PAD_Init();
WPAD_Init();
initialise_reset_buttons();
printf("To exit, hold A on controller #1 or press the reset
button.\n");
- initialise_network();
initialise_fs();
printf("To remount a device, hold B on controller #1.\n");
}
=======================================
--- /branches/0.0.22/source/net.c Sun Aug 22 00:38:08 2010
+++ /branches/0.0.22/source/net.c Tue Aug 24 04:32:37 2010
@@ -21,7 +21,6 @@
printf("Waiting for network to initialise...\n");
s32 result = -1;
while (!check_reset_synchronous() && result < 0) {
- net_deinit();
while (!check_reset_synchronous() && (result = net_init()) ==
-EAGAIN);
if (result < 0) printf("net_init() failed: [%i] %s,
retrying...\n", result, strerror(-result));
}