1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
else if(!strcmp(command,"PORT"))
{
unsigned char act_port[2];
int act_ip[4], port_dec;
char ip_decimal[40];
active=1;
sscanf(command, "PORT %d,%d,%d,%d,%d,%d",&act_ip[0],&act_ip[1],&act_ip[2],&act_ip[3], &act_port[0], &act_port[1]);
local_data_addr_act.sin_family=AF_INET;
sprintf(ip_decimal, "%d.%d.%d.%d", act_ip[0], act_ip[1], act_ip[2], act_ip[3]);
local_data_addr_act.sin_addr.s_addr=inet_addr(ip_decimal);
port_dec=act_port[0];
port_dec=port_dec<<8;
port_dec=port_dec+act_port[1];
local_data_addr_act.sin_port=htons(port_dec);
if (connect(s_data_act,(struct sockaddr*)&local_data_addr_act, (int)sizeof(struct sockaddr))!=0){
printf("%s%d\n",inet_ntoa(local_data_addr_act.sin_addr),ntohs(local_data_addr_act.sin_port));
sprintf(buf, "425\r\n");
send(sock2, buf, strlen(buf), 0);
close(s_data_act);
}
else{
sprintf(buf, "200\r\n");
send(sock2, buf, strlen(buf), 0);
}
}
|