#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 113 of file ftp_funcs.c.
121 snprintf (buf, 7,
"PASV\r\n");
123 bzero (buf,
sizeof (buf));
124 bzero (addr,
sizeof (
struct sockaddr_in));
125 if (
recv_line (soc, buf,
sizeof (buf) - 1) < 0)
128 if (strncmp (buf,
"227", 3) != 0)
131 t = strchr (buf,
'(');
141 l[0] = (
unsigned char) atoi (t);
147 l[1] = (
unsigned char) atoi (s);
153 l[2] = (
unsigned char) atoi (t);
159 l[3] = (
unsigned char) atoi (s);
165 l[4] = (
unsigned char) atoi (t);
171 l[5] = (
unsigned char) atoi (s);
172 a = (
unsigned long *) l;
173 p = (
unsigned short *) (l + 4);
175 addr->sin_addr.s_addr = *a;
177 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 29 of file ftp_funcs.c.
35 buf[
sizeof (buf) - 1] =
'\0';
36 n =
recv_line (soc, buf,
sizeof (buf) - 1);
40 if (strncmp (buf,
"220", 3) != 0)
46 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
48 n =
recv_line (soc, buf,
sizeof (buf) - 1);
58 snprintf (buf,
sizeof (buf),
"USER %s\r\n", username);
60 n =
recv_line (soc, buf,
sizeof (buf) - 1);
63 if (strncmp (buf,
"230", 3) == 0)
66 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
68 n =
recv_line (soc, buf,
sizeof (buf) - 1);
74 if (strncmp (buf,
"331", 3) != 0)
81 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
83 n =
recv_line (soc, buf,
sizeof (buf) - 1);
90 snprintf (buf,
sizeof (buf),
"PASS %s\r\n", passwd);
92 n =
recv_line (soc, buf,
sizeof (buf) - 1);
96 if (strncmp (buf,
"230", 3) != 0)
103 while (buf[3] ==
'-' && n > 0 &&
counter < 1024)
105 n =
recv_line (soc, buf,
sizeof (buf) - 1);
References counter, recv_line(), and write_stream_connection().
Referenced by nasl_ftp_log_in().