static void run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { void *addr; size_t alen; struct sockaddr_in *v4; struct sockaddr_in expect; asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); GNUNET_assert (asock != NULL); GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); GNUNET_assert (GNUNET_OK == GNUNET_CONNECTION_get_address (asock, &addr, &alen)); GNUNET_assert (alen == sizeof (struct sockaddr_in)); v4 = addr; memset (&expect, 0, sizeof (expect)); #if HAVE_SOCKADDR_IN_SIN_LEN expect.sin_len = sizeof (expect); #endif expect.sin_family = AF_INET; expect.sin_port = v4->sin_port; expect.sin_addr.s_addr = htonl (INADDR_LOOPBACK); GNUNET_assert (0 == memcmp (&expect, v4, alen)); GNUNET_free (addr); GNUNET_CONNECTION_destroy (lsock); GNUNET_CONNECTION_receive (asock, 1024, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, cls); }
static void run_accept (void *cls) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n"); asock = GNUNET_CONNECTION_create_from_accept (NULL, NULL, ls); GNUNET_assert (asock != NULL); GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test destroys listen socket\n"); GNUNET_CONNECTION_destroy (lsock); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks to receive on accepted socket\n"); GNUNET_CONNECTION_receive (asock, 1024, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, cls); }