ftp测试脚本

#include "lrs.h"
extern char *strtok(char *string, const char *delimiters );
Action()
{
 char *BufVal;
 char *token;
 char hostport[255];
 char portinfo[8];
 char PortNum[255];
    char cVal[8];
 char cHighVal[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);
//  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);
 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_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_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"
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"
send  buf9 106496
 "…………"
recv  buf10 22
 "226 File receive OK.\r\n"
send  buf11 6
 "QUIT\r\n"
recv  buf12 14
 "221 Goodbye.\r\n"

-1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值