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.

hellotest.c 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/hello.h>
  8. static void test_hello_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_hello ( struct sockaddr_tcpip *server, const char *message ) {
  23. /* Quick and dirty hack */
  24. struct sockaddr_in *sin = ( struct sockaddr_in * ) server;
  25. struct hello_request hello;
  26. int rc;
  27. printf ( "Saying \"%s\" to %s:%d\n", message,
  28. inet_ntoa ( sin->sin_addr ), ntohs ( sin->sin_port ) );
  29. memset ( &hello, 0, sizeof ( hello ) );
  30. memcpy ( &hello.tcp.peer, server, sizeof ( hello.tcp.peer ) );
  31. hello.message = message;
  32. hello.callback = test_hello_callback;
  33. rc = async_wait ( say_hello ( &hello ) );
  34. if ( rc ) {
  35. printf ( "HELLO fetch failed\n" );
  36. }
  37. }