11#include "ftpc.h"
22
3- un_l2cval remote_ip ;
4- uint16_t remote_port ;
5- un_l2cval local_ip ;
6- uint16_t local_port ;
3+ un_l2cval FTP_remote_ip ;
4+ uint16_t FTP_remote_port ;
5+ un_l2cval FTP_local_ip ;
6+ uint16_t FTP_local_port ;
77uint8_t connect_state_control_ftpc = 0 ;
88uint8_t connect_state_data_ftpc = 0 ;
99uint8_t gModeActivePassiveflag = 0 ;
@@ -21,11 +21,11 @@ void ftpc_init(uint8_t * src_ip)
2121{
2222 ftpc .dsock_mode = ACTIVE_MODE ;
2323
24- local_ip .cVal [0 ] = src_ip [0 ];
25- local_ip .cVal [1 ] = src_ip [1 ];
26- local_ip .cVal [2 ] = src_ip [2 ];
27- local_ip .cVal [3 ] = src_ip [3 ];
28- local_port = 35000 ;
24+ FTP_local_ip .cVal [0 ] = src_ip [0 ];
25+ FTP_local_ip .cVal [1 ] = src_ip [1 ];
26+ FTP_local_ip .cVal [2 ] = src_ip [2 ];
27+ FTP_local_ip .cVal [3 ] = src_ip [3 ];
28+ FTP_local_port = 35000 ;
2929 strcpy (ftpc .workingdir , "/" );
3030 socket (CTRL_SOCK , Sn_MR_TCP , FTP_destport , 0x0 );
3131}
@@ -77,7 +77,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
7777 else {
7878 wiz_NetInfo gWIZNETINFO ;
7979 ctlnetwork (CN_GET_NETINFO , (void * ) & gWIZNETINFO );
80- sprintf (dat ,"PORT %d,%d,%d,%d,%d,%d\r\n" , gWIZNETINFO .ip [0 ], gWIZNETINFO .ip [1 ], gWIZNETINFO .ip [2 ], gWIZNETINFO .ip [3 ], (uint8_t )(local_port >>8 ), (uint8_t )(local_port & 0x00ff ));
80+ sprintf (dat ,"PORT %d,%d,%d,%d,%d,%d\r\n" , gWIZNETINFO .ip [0 ], gWIZNETINFO .ip [1 ], gWIZNETINFO .ip [2 ], gWIZNETINFO .ip [3 ], (uint8_t )(FTP_local_port >>8 ), (uint8_t )(FTP_local_port & 0x00ff ));
8181 send (CTRL_SOCK , (uint8_t * )dat , strlen (dat ));
8282 Command .First = f_dir ;
8383
@@ -96,7 +96,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
9696 else {
9797 wiz_NetInfo gWIZNETINFO ;
9898 ctlnetwork (CN_GET_NETINFO , (void * ) & gWIZNETINFO );
99- sprintf (dat ,"PORT %d,%d,%d,%d,%d,%d\r\n" , gWIZNETINFO .ip [0 ], gWIZNETINFO .ip [1 ], gWIZNETINFO .ip [2 ], gWIZNETINFO .ip [3 ], (uint8_t )(local_port >>8 ), (uint8_t )(local_port & 0x00ff ));
99+ sprintf (dat ,"PORT %d,%d,%d,%d,%d,%d\r\n" , gWIZNETINFO .ip [0 ], gWIZNETINFO .ip [1 ], gWIZNETINFO .ip [2 ], gWIZNETINFO .ip [3 ], (uint8_t )(FTP_local_port >>8 ), (uint8_t )(FTP_local_port & 0x00ff ));
100100 send (CTRL_SOCK , (uint8_t * )dat , strlen (dat ));
101101 Command .First = f_put ;
102102
@@ -114,7 +114,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
114114 else {
115115 wiz_NetInfo gWIZNETINFO ;
116116 ctlnetwork (CN_GET_NETINFO , (void * ) & gWIZNETINFO );
117- sprintf (dat ,"PORT %d,%d,%d,%d,%d,%d\r\n" , gWIZNETINFO .ip [0 ], gWIZNETINFO .ip [1 ], gWIZNETINFO .ip [2 ], gWIZNETINFO .ip [3 ], (uint8_t )(local_port >>8 ), (uint8_t )(local_port & 0x00ff ));
117+ sprintf (dat ,"PORT %d,%d,%d,%d,%d,%d\r\n" , gWIZNETINFO .ip [0 ], gWIZNETINFO .ip [1 ], gWIZNETINFO .ip [2 ], gWIZNETINFO .ip [3 ], (uint8_t )(FTP_local_port >>8 ), (uint8_t )(FTP_local_port & 0x00ff ));
118118 send (CTRL_SOCK , (uint8_t * )dat , strlen (dat ));
119119 Command .First = f_get ;
120120
@@ -416,25 +416,25 @@ uint8_t ftpc_run(uint8_t * dbuf)
416416 case SOCK_CLOSED :
417417 if (ftpc .dsock_state == DATASOCK_READY ){
418418 if (ftpc .dsock_mode == PASSIVE_MODE ){
419- printf ("%d:FTPDataStart, port : %d\r\n" ,DATA_SOCK , local_port );
420- if ((ret = socket (DATA_SOCK , Sn_MR_TCP , local_port , 0x0 )) != DATA_SOCK ){
419+ printf ("%d:FTPDataStart, port : %d\r\n" ,DATA_SOCK , FTP_local_port );
420+ if ((ret = socket (DATA_SOCK , Sn_MR_TCP , FTP_local_port , 0x0 )) != DATA_SOCK ){
421421 printf ("%d:socket() error:%ld\r\n" , DATA_SOCK , ret );
422422 close (DATA_SOCK );
423423 return ret ;
424424 }
425- local_port ++ ;
426- if (local_port > 50000 )
427- local_port = 35000 ;
425+ FTP_local_port ++ ;
426+ if (FTP_local_port > 50000 )
427+ FTP_local_port = 35000 ;
428428 }else {
429- printf ("%d:FTPDataStart, port : %d\r\n" ,DATA_SOCK , local_port );
430- if ((ret = socket (DATA_SOCK , Sn_MR_TCP , local_port , 0x0 )) != DATA_SOCK ){
429+ printf ("%d:FTPDataStart, port : %d\r\n" ,DATA_SOCK , FTP_local_port );
430+ if ((ret = socket (DATA_SOCK , Sn_MR_TCP , FTP_local_port , 0x0 )) != DATA_SOCK ){
431431 printf ("%d:socket() error:%ld\r\n" , DATA_SOCK , ret );
432432 close (DATA_SOCK );
433433 return ret ;
434434 }
435- local_port ++ ;
436- if (local_port > 50000 )
437- local_port = 35000 ;
435+ FTP_local_port ++ ;
436+ if (FTP_local_port > 50000 )
437+ FTP_local_port = 35000 ;
438438 }
439439 ftpc .dsock_state = DATASOCK_START ;
440440 }
@@ -450,7 +450,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
450450 gDataSockReady = 1 ;
451451 printf ("%d:Listen ok\r\n" ,DATA_SOCK );
452452 }else {
453- if ((ret = connect (DATA_SOCK , remote_ip .cVal , remote_port )) != SOCK_OK ){
453+ if ((ret = connect (DATA_SOCK , FTP_remote_ip .cVal , FTP_remote_port )) != SOCK_OK ){
454454 printf ("%d:Connect error\r\n" , DATA_SOCK );
455455 return ret ;
456456 }
@@ -468,7 +468,7 @@ uint8_t ftpc_run(uint8_t * dbuf)
468468char proc_ftpc (char * buf )
469469{
470470 uint16_t Responses ;
471- uint8_t dat [30 ]= {0 ,};
471+ char dat [30 ]= {0 ,};
472472
473473 Responses = (buf [0 ]- '0' )* 100 + (buf [1 ]- '0' )* 10 + (buf [2 ]- '0' );
474474
@@ -553,23 +553,23 @@ int pportc(char * arg)
553553 {
554554 if (i == 0 ) tok = strtok (NULL ,",\r\n" );
555555 else tok = strtok (NULL ,"," );
556- remote_ip .cVal [i ] = (uint8_t )atoi (tok );
556+ FTP_remote_ip .cVal [i ] = (uint8_t )atoi (tok );
557557 if (!tok ){
558558 printf ("bad pport : %s\r\n" , arg );
559559 return -1 ;
560560 }
561561 }
562- remote_port = 0 ;
562+ FTP_remote_port = 0 ;
563563 for (i = 0 ; i < 2 ; i ++ ){
564564 tok = strtok (NULL ,",\r\n" );
565- remote_port <<= 8 ;
566- remote_port += atoi (tok );
565+ FTP_remote_port <<= 8 ;
566+ FTP_remote_port += atoi (tok );
567567 if (!tok ){
568568 printf ("bad pport : %s\r\n" , arg );
569569 return -1 ;
570570 }
571571 }
572- printf ("ip : %d.%d.%d.%d, port : %d\r\n" , remote_ip .cVal [0 ], remote_ip .cVal [1 ], remote_ip .cVal [2 ], remote_ip .cVal [3 ], remote_port );
572+ printf ("ip : %d.%d.%d.%d, port : %d\r\n" , FTP_remote_ip .cVal [0 ], FTP_remote_ip .cVal [1 ], FTP_remote_ip .cVal [2 ], FTP_remote_ip .cVal [3 ], FTP_remote_port );
573573 return 0 ;
574574}
575575uint8_t * User_Keyboard_MSG ()
0 commit comments