#include "lrs.h"
extern char *strtok(char *string, const char *delimiters );
Action()
{
char *BufVal;
Action()
{
char *BufVal;
char *token;
char hostport[255];
char portinfo[8];
char portinfo[8];
char PortNum[255];
char cVal[8];
char cHighVal[8];
char cLowVal[8];
char cLowVal[8];
int iVal,iLength,i,j;
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);
lrs_send("socket0", "pasvbuf0", LrsLastArg);
lrs_receive("socket0", "pasvbuf1", LrsLastArg);
// Get the Local Port of the Local Host on socket0*/
lrs_get_last_received_buffer("socket0",&BufVal,&iLength);
lr_output_message("The buffer is:%s", BufVal);
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);
// 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_eval_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);
token=strtok(lr_eval_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);
lrs_free_buffer(BufVal);
// creat data socket
lrs_create_socket("socket1", "TCP", "LocalHost=0", "RemoteHost=192.168.0.100:21", LrsLastArg);
lrs_send("socket1", "vpnbuf1", LrsLastArg);
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");
return 0;
}
}
data.ws:
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"
"CONNECT OK TAURUS/1.0\r\n"
"220 (vsFTPd 1.1.3)\r\n"
send buf1 11
"USER libh\r\n"
"USER libh\r\n"
recv buf2 34
"331 Please specify the password.\r\n"
"331 Please specify the password.\r\n"
send buf3 11
"PASS 1111\r\n"
"PASS 1111\r\n"
recv buf4 33
"230 Login successful. Have fun.\r\n"
"230 Login successful. Have fun.\r\n"
send pasvbuf0 6
"PASV\r\n"
"PASV\r\n"
recv pasvbuf1 49
"227 Entering Passive Mode (192,168,0,16,113,74)\r\n"
"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"
"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"
"CONNECT OK TAURUS/1.0\r\n"
send buf7 15
"STOR 100k.doc\r\n"
"STOR 100k.doc\r\n"
recv buf8 22
"150 Ok to send data.\r\n"
"150 Ok to send data.\r\n"
send buf9 106496
"…………"
recv buf10 22
"226 File receive OK.\r\n"
"226 File receive OK.\r\n"
send buf11 6
"QUIT\r\n"
"QUIT\r\n"
recv buf12 14
"221 Goodbye.\r\n"
"221 Goodbye.\r\n"
-1