#include "ftp_funcs.h"
#include "network.h"
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
◆ ftp_get_pasv_address()
| int ftp_get_pasv_address |
( |
int |
soc, |
|
|
struct sockaddr_in * |
addr |
|
) |
| |
Definition at line 101 of file ftp_funcs.c.
109 snprintf (buf, 7,
"PASV\r\n");
111 bzero (buf,
sizeof (buf));
112 bzero (addr,
sizeof (
struct sockaddr_in));
113 if (
recv_line (soc, buf,
sizeof (buf) - 1) < 0)
116 if (strncmp (buf,
"227", 3) != 0)
119 t = strchr (buf,
'(');
129 l[0] = (
unsigned char) atoi (t);
135 l[1] = (
unsigned char) atoi (s);
141 l[2] = (
unsigned char) atoi (t);
147 l[3] = (
unsigned char) atoi (s);
153 l[4] = (
unsigned char) atoi (t);
159 l[5] = (
unsigned char) atoi (s);
161 p = (
unsigned short *) (l + 4);
163 addr->sin_addr.s_addr = *a;
165 addr->sin_family = AF_INET;
References recv_line(), and write_stream_connection().
Referenced by nasl_ftp_get_pasv_address().
◆ ftp_log_in()
| int ftp_log_in |
( |
int |
soc, |
|
|
char * |
username, |
|
|
char * |
passwd |
|
) |
| |
Definition at line 17 of file ftp_funcs.c.
23 buf[
sizeof (buf) - 1] =
'\0';
24 n =
recv_line (soc, buf,
sizeof (buf) - 1);
28 if (strncmp (buf,
"220", 3) != 0)
34 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
36 n =
recv_line (soc, buf,
sizeof (buf) - 1);
46 snprintf (buf,
sizeof (buf),
"USER %s\r\n", username);
48 n =
recv_line (soc, buf,
sizeof (buf) - 1);
51 if (strncmp (buf,
"230", 3) == 0)
54 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
56 n =
recv_line (soc, buf,
sizeof (buf) - 1);
62 if (strncmp (buf,
"331", 3) != 0)
69 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
71 n =
recv_line (soc, buf,
sizeof (buf) - 1);
78 snprintf (buf,
sizeof (buf),
"PASS %s\r\n", passwd);
80 n =
recv_line (soc, buf,
sizeof (buf) - 1);
84 if (strncmp (buf,
"230", 3) != 0)
91 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
93 n =
recv_line (soc, buf,
sizeof (buf) - 1);
References counter, recv_line(), and write_stream_connection().
Referenced by nasl_ftp_log_in().