Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sv_handle_pasv(char *str, int csfd, status_t *stat)
- {
- struct sockaddr_in addr;
- socklen_t size;
- char *ip;
- int i;
- char buff[50];
- if (stat->ds_fd > - 1)
- reset_dc(stat);
- size = sizeof(addr);
- err(getsockname(csfd, (struct sockaddr*)&addr, &size));
- addr.sin_port = 0;
- addr.sin_family = AF_INET;
- create_listen_socket(&addr, &stat->ds_fd);
- send_command("227 Entering Passive Mode. ", csfd);
- ip = inet_ntoa(addr.sin_addr);
- i = 0;
- while (ip[i] != 0)
- {
- if (ip[i] == '.')
- ip[i] = ',';
- i++;
- }
- send_command(ip, csfd);
- send_command(",", csfd);
- err(getsockname(stat->ds_fd, (struct sockaddr*)&addr, &size));
- printf("Opening socket on: %s:%d\n",
- inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
- sprintf(buff, "%d", ntohs(addr.sin_port) / 256);
- send_command(buff, csfd);
- send_command(",", csfd);
- sprintf(buff, "%d", (ntohs(addr.sin_port) % 256));
- send_command(buff, csfd);
- send_command("\n", csfd);
- stat->dcs_fd = accept(stat->ds_fd, (struct sockaddr*)&addr, &size);
- err(stat->dcs_fd);
- printf("Client connected from: %s:%d\n",
- inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
- (void)str;
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement