extern char *strtok(char *string, const char *delimiters );
Action()
{
char *BufVal;
char hostport[255];
char portinfo[8];
char cHighVal[8];
char cLowVal[8];
lrs_create_socket("socket0", "TCP", "LocalHost=0", "RemoteHost=192.168.0.100:21", LrsLastArg);
lrs_send("socket0","vpnbuf0",LrsLastArg);
lrs_receive("socket0", "buf0", LrsLastArg);
lrs_send("socket0", "buf1", LrsLastArg);
lrs_receive("socket0", "buf2", LrsLastArg);
lrs_send("socket0", "buf3", LrsLastArg);
lrs_receive("socket0", "buf4", LrsLastArg);
//send PASV
lrs_send("socket0", "pasvbuf0", LrsLastArg);
lrs_receive("socket0", "pasvbuf1", LrsLastArg);
// Get the Local Port of the Local Host . socket0*/
lrs_get_last_received_buffer("socket0",&BufVal,&iLength);
lr_output_message("The buffer is:%s", BufVal);
strcpy(PortNum,BufVal);
// lr_output_message("PortNum Conetnt %s", PortNum);
for(i=0,j=40;i<3;i++,j++)
{
cHighVal[i]=PortNum[j];
}
lr_output_message("cHignVal conent %s",cHighVal);
j=44;
token=strtok(lr_._string(&PortNum[j]),")");
if(token != NULL)
strcpy(cLowVal,token);
lr_output_message("cLowVal is:%s",cLowVal);
iVal=atoi(cHighVal)*256+atoi(cLowVal);
lr_output_message("cHighVal*256 id %d",atoi(cHighVal)*256);
lr_output_message("iVal %d",iVal);
// lr_output_message("cVal %s",itoa(iVal,cVal,10));
itoa(iVal,cVal,10);
lr_output_message("cVal %s",cVal);
//set the propority's value
lr_save_string(cVal,"portinfo");
//strcpy(&portinfo,&cVal);
//lr_output_message("portinfo is :%s",portinfo);
// creat data socket
lrs_create_socket("socket1", "TCP", "LocalHost=0", "RemoteHost=192.168.0.100:21", LrsLastArg);
lrs_send("socket1", "vpnbuf1", LrsLastArg);
lrs_receive("socket1", "vpnbuf2", LrsLastArg);
lrs_send("socket0", "buf7", LrsLastArg);
lrs_receive("socket0", "buf8", LrsLastArg);
// lrs_accept_connection("socket1", "socket2");
// lrs_close_socket("socket1");
lrs_send("socket1", "buf9", LrsLastArg);
lrs_close_socket("socket1");
lrs_receive("socket0", "buf10", LrsLastArg);
lrs_send("socket0", "buf11", LrsLastArg);
lrs_receive("socket0", "buf12", LrsLastArg);
lrs_close_socket("socket0");
send vpnbuf0 81
"CONNECT 35622ebb TAURUS/1.0\r\n"
"COOKIE: TaurusSessionID=w1mO0LX84O7EHLnQwBmw6g==\r\n\r\n"
recv buf0 43
"CONNECT OK TAURUS/1.0\r\n"
"220 (vsFTPd 1.1.3)\r\n"
send buf1 11
"USER libh\r\n"
recv buf2 34
"331 Please specify the password.\r\n"
send buf3 11
"PASS 1111\r\n"
recv buf4 33
"230 Login successful. Have fun.\r\n"
send pasvbuf0 6
"PASV\r\n"
recv pasvbuf1 49
"227 Entering Passive Mode (192,168,0,16,113,74)\r\n"
send vpnbuf1 87
"CONNECT 35622ebb:<portinfo> TAURUS/1.0\r\n"
"COOKIE: TaurusSessionID=w1mO0LX84O7EHLnQwBmw6g==\r\n\r\n"
recv vpnbuf2 23
"CONNECT OK TAURUS/1.0\r\n"
send buf7 15
"STOR 100k.doc\r\n"
recv buf8 22
"150 Ok to send data.\r\n"
recv buf10 22
"226 File receive OK.\r\n"
recv buf12 14
"221 Goodbye.\r\n"