You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ftptest.c 902B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <stdint.h>
  2. #include <string.h>
  3. #include <byteswap.h>
  4. #include <console.h>
  5. #include <vsprintf.h>
  6. #include <gpxe/async.h>
  7. #include <gpxe/ftp.h>
  8. static void test_ftp_callback ( char *data, size_t len ) {
  9. unsigned int i;
  10. char c;
  11. for ( i = 0 ; i < len ; i++ ) {
  12. c = data[i];
  13. if ( c == '\r' ) {
  14. /* Print nothing */
  15. } else if ( ( c == '\n' ) || ( c >= 32 ) || ( c <= 126 ) ) {
  16. putchar ( c );
  17. } else {
  18. putchar ( '.' );
  19. }
  20. }
  21. }
  22. void test_ftp ( struct in_addr server, const char *filename ) {
  23. struct ftp_request ftp;
  24. int rc;
  25. printf ( "FTP fetching %s:%s\n", inet_ntoa ( server ), filename );
  26. memset ( &ftp, 0, sizeof ( ftp ) );
  27. ftp.tcp.sin.sin_addr.s_addr = server.s_addr;
  28. ftp.tcp.sin.sin_port = htons ( FTP_PORT );
  29. ftp.filename = filename;
  30. ftp.callback = test_ftp_callback;
  31. rc = async_wait ( ftp_get ( &ftp ) );
  32. if ( rc ) {
  33. printf ( "FTP fetch failed\n" );
  34. }
  35. }