#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <netinet/in.h>
#include "network.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 124 of file ftp_funcs.c.
132 snprintf (buf, 7,
"PASV\r\n");
134 bzero (buf,
sizeof (buf));
135 bzero (addr,
sizeof (
struct sockaddr_in));
138 if (strncmp (buf,
"227", 3) != 0)
141 t = strchr (buf,
'(');
151 l[0] = (
unsigned char) atoi (t);
157 l[1] = (
unsigned char) atoi (s);
163 l[2] = (
unsigned char) atoi (t);
169 l[3] = (
unsigned char) atoi (s);
175 l[4] = (
unsigned char) atoi (t);
181 l[5] = (
unsigned char) atoi (s);
182 a = (
unsigned long *) l;
183 p = (
unsigned short *) (l + 4);
185 addr->sin_addr.s_addr = *a;
187 addr->sin_family = AF_INET;
int recv_line(int soc, char *buf, size_t bufsiz)
Reads a text from the socket stream into the argument buffer, always.
int write_stream_connection(int fd, void *buf0, int n)
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 37 of file ftp_funcs.c.
43 buf[
sizeof (buf) - 1] =
'\0';
44 n =
recv_line (soc, buf,
sizeof (buf) - 1);
48 if (strncmp (buf,
"220", 3) != 0)
54 while (buf[3] ==
'-' && n > 0 && counter < 1024)
56 n =
recv_line (soc, buf,
sizeof (buf) - 1);
67 snprintf (buf,
sizeof (buf),
"USER %s\r\n", username);
69 n =
recv_line (soc, buf,
sizeof (buf) - 1);
72 if (strncmp (buf,
"230", 3) == 0)
75 while (buf[3] ==
'-' && n > 0 && counter < 1024)
77 n =
recv_line (soc, buf,
sizeof (buf) - 1);
83 if (strncmp (buf,
"331", 3) != 0)
90 while (buf[3] ==
'-' && n > 0 && counter < 1024)
92 n =
recv_line (soc, buf,
sizeof (buf) - 1);
100 snprintf (buf,
sizeof (buf),
"PASS %s\r\n", passwd);
102 n =
recv_line (soc, buf,
sizeof (buf) - 1);
106 if (strncmp (buf,
"230", 3) != 0)
113 while (buf[3] ==
'-' && n > 0 && counter < 1024)
115 n =
recv_line (soc, buf,
sizeof (buf) - 1);
int recv_line(int soc, char *buf, size_t bufsiz)
Reads a text from the socket stream into the argument buffer, always.
int write_stream_connection(int fd, void *buf0, int n)
Referenced by nasl_ftp_log_in().