void process_requests() { float temp_rate; if (debug) open_debug_file(); while (1) { recv_request(); switch (netperf_request.content.request_type) { case DEBUG_ON: netperf_response.content.response_type = DEBUG_OK; /* dump_request already present in recv_request; redundant? */ if (!debug) { debug++; open_debug_file(); dump_request(); } send_response(); break; case DEBUG_OFF: if (debug) debug--; netperf_response.content.response_type = DEBUG_OK; send_response(); /* +SAF why??? */ if (!debug) { fclose(where); #if !defined(WIN32) && !defined(MPE) && !defined(__VMS) /* For Unix: reopen the debug write file descriptor to "/dev/null" */ /* and redirect stdout to it. */ fflush (stdout); where = fopen ("/dev/null", "w"); if (where == NULL) { perror ("netserver: reopening debug fp for writing: /dev/null"); exit (1); } if (close (STDOUT_FILENO) == -1) { perror ("netserver: closing stdout file descriptor"); exit (1); } if (dup (fileno (where)) == -1) { perror ("netserver: duplicate /dev/null write file descr. to stdout"); exit (1); } #endif /* !WIN32 !MPE !__VMS */ } break; case CPU_CALIBRATE: netperf_response.content.response_type = CPU_CALIBRATE; temp_rate = calibrate_local_cpu(0.0); bcopy((char *)&temp_rate, (char *)netperf_response.content.test_specific_data, sizeof(temp_rate)); bcopy((char *)&lib_num_loc_cpus, (char *)netperf_response.content.test_specific_data + sizeof(temp_rate), sizeof(lib_num_loc_cpus)); if (debug) { fprintf(where,"netserver: sending CPU information:"); fprintf(where,"rate is %g num cpu %d\n",temp_rate,lib_num_loc_cpus); fflush(where); } /* we need the cpu_start, cpu_stop in the looper case to kill the */ /* child proceses raj 7/95 */ #ifdef USE_LOOPER cpu_start(1); cpu_stop(1,&temp_rate); #endif /* USE_LOOPER */ send_response(); break; case DO_TCP_STREAM: recv_tcp_stream(); break; case DO_TCP_MAERTS: recv_tcp_maerts(); break; case DO_TCP_RR: recv_tcp_rr(); break; case DO_TCP_CRR: recv_tcp_conn_rr(); break; case DO_TCP_CC: recv_tcp_cc(); break; #ifdef DO_1644 case DO_TCP_TRR: recv_tcp_tran_rr(); break; #endif /* DO_1644 */ #ifdef DO_NBRR case DO_TCP_NBRR: recv_tcp_nbrr(); break; #endif /* DO_NBRR */ case DO_UDP_STREAM: recv_udp_stream(); break; case DO_UDP_RR: recv_udp_rr(); break; #ifdef WANT_DLPI case DO_DLPI_CO_RR: recv_dlpi_co_rr(); break; case DO_DLPI_CL_RR: recv_dlpi_cl_rr(); break; case DO_DLPI_CO_STREAM: recv_dlpi_co_stream(); break; case DO_DLPI_CL_STREAM: recv_dlpi_cl_stream(); break; #endif /* WANT_DLPI */ #ifdef WANT_UNIX case DO_STREAM_STREAM: recv_stream_stream(); break; case DO_STREAM_RR: recv_stream_rr(); break; case DO_DG_STREAM: recv_dg_stream(); break; case DO_DG_RR: recv_dg_rr(); break; #endif /* WANT_UNIX */ #ifdef WANT_XTI case DO_XTI_TCP_STREAM: recv_xti_tcp_stream(); break; case DO_XTI_TCP_RR: recv_xti_tcp_rr(); break; case DO_XTI_UDP_STREAM: recv_xti_udp_stream(); break; case DO_XTI_UDP_RR: recv_xti_udp_rr(); break; #endif /* WANT_XTI */ #ifdef WANT_SCTP case DO_SCTP_STREAM: recv_sctp_stream(); break; case DO_SCTP_STREAM_MANY: recv_sctp_stream_1toMany(); break; case DO_SCTP_RR: recv_sctp_rr(); break; case DO_SCTP_RR_MANY: recv_sctp_rr_1toMany(); break; #endif #ifdef WANT_SDP case DO_SDP_STREAM: recv_sdp_stream(); break; case DO_SDP_MAERTS: recv_sdp_maerts(); break; case DO_SDP_RR: recv_sdp_rr(); break; #endif default: fprintf(where,"unknown test number %d\n", netperf_request.content.request_type); fflush(where); netperf_response.content.serv_errno=998; send_response(); break; } } }
void process_requests() { float temp_rate; if (debug) { fprintf(where, "%s: enter\n", __FUNCTION__); fflush(where); } /* if the netserver was started with a passphrase, look for it in the first request to arrive. if there is no passphrase in the first request we will end-up dumping the control connection. raj 2012-01-23 */ if ((passphrase != NULL) && (recv_passphrase())) return; while (1) { if (recv_request() <= 0) { close(server_sock); return; } switch (netperf_request.content.request_type) { case DEBUG_ON: netperf_response.content.response_type = DEBUG_OK; if (!suppress_debug) { debug++; if (debug == 1) { /* we just flipped-on debugging, dump the request because recv_request/recv_request_n will not have dumped it as its dump_request() call is conditional on debug being set. raj 2011-07-08 */ dump_request(); } } send_response(); break; case DEBUG_OFF: if (debug) debug--; netperf_response.content.response_type = DEBUG_OK; send_response(); /* we used to take the trouble to close the debug file, but SAF asked a good question when he asked "Why?" and since I cannot think of a good reason, I have removed the code. raj 2011-07-08 */ break; case DO_SYSINFO: { netperf_response.content.response_type = SYSINFO_RESPONSE; snprintf((char *)netperf_response.content.test_specific_data, sizeof(netperf_response.content.test_specific_data), "%c%s%c%s%c%s%c%s", ',', "Deprecated", ',' , "Deprecated", ',', "Deprecated", ',', "Deprecated"); send_response_n(0); break; } case CPU_CALIBRATE: netperf_response.content.response_type = CPU_CALIBRATE; temp_rate = calibrate_local_cpu(0.0); bcopy((char *)&temp_rate, (char *)netperf_response.content.test_specific_data, sizeof(temp_rate)); bcopy((char *)&lib_num_loc_cpus, (char *)netperf_response.content.test_specific_data + sizeof(temp_rate), sizeof(lib_num_loc_cpus)); if (debug) { fprintf(where, "netserver: sending CPU information: rate is %g num cpu %d\n", temp_rate, lib_num_loc_cpus); fflush(where); } /* we need the cpu_start, cpu_stop in the looper case to kill the child proceses raj 7/95 */ #ifdef USE_LOOPER cpu_start(1); cpu_stop(1,&temp_rate); #endif /* USE_LOOPER */ send_response(); break; case DO_TCP_STREAM: recv_tcp_stream(); break; case DO_TCP_MAERTS: recv_tcp_maerts(); break; case DO_TCP_RR: recv_tcp_rr(); break; case DO_TCP_CRR: recv_tcp_conn_rr(); break; case DO_TCP_CC: recv_tcp_cc(); break; #ifdef DO_1644 case DO_TCP_TRR: recv_tcp_tran_rr(); break; #endif /* DO_1644 */ #ifdef DO_NBRR case DO_TCP_NBRR: recv_tcp_nbrr(); break; #endif /* DO_NBRR */ case DO_UDP_STREAM: recv_udp_stream(); break; case DO_UDP_RR: recv_udp_rr(); break; #ifdef WANT_DLPI case DO_DLPI_CO_RR: recv_dlpi_co_rr(); break; case DO_DLPI_CL_RR: recv_dlpi_cl_rr(); break; case DO_DLPI_CO_STREAM: recv_dlpi_co_stream(); break; case DO_DLPI_CL_STREAM: recv_dlpi_cl_stream(); break; #endif /* WANT_DLPI */ #ifdef WANT_UNIX case DO_STREAM_STREAM: recv_stream_stream(); break; case DO_STREAM_RR: recv_stream_rr(); break; case DO_DG_STREAM: recv_dg_stream(); break; case DO_DG_RR: recv_dg_rr(); break; #endif /* WANT_UNIX */ #ifdef WANT_XTI case DO_XTI_TCP_STREAM: recv_xti_tcp_stream(); break; case DO_XTI_TCP_RR: recv_xti_tcp_rr(); break; case DO_XTI_UDP_STREAM: recv_xti_udp_stream(); break; case DO_XTI_UDP_RR: recv_xti_udp_rr(); break; #endif /* WANT_XTI */ #ifdef WANT_SCTP case DO_SCTP_STREAM: recv_sctp_stream(); break; case DO_SCTP_STREAM_MANY: recv_sctp_stream_1toMany(); break; case DO_SCTP_RR: recv_sctp_rr(); break; case DO_SCTP_RR_MANY: recv_sctp_rr_1toMany(); break; #endif #ifdef WANT_SDP case DO_SDP_STREAM: recv_sdp_stream(); break; case DO_SDP_MAERTS: recv_sdp_maerts(); break; case DO_SDP_RR: recv_sdp_rr(); break; #endif #ifdef WANT_OMNI case DO_OMNI: recv_omni(); break; #endif case PASSPHRASE: if (debug) { fprintf(where,"Ignoring an unexpected passphrase control message\n"); fflush(where); } break; default: fprintf(where,"unknown test number %d\n", netperf_request.content.request_type); fflush(where); netperf_response.content.serv_errno=998; send_response(); break; } } }
void process_requests() { float temp_rate; while (1) { recv_request(); switch (netperf_request.content.request_type) { case DEBUG_ON: netperf_response.content.response_type = DEBUG_OK; /* dump_request already present in recv_request; redundant? */ if (!debug) { debug++; dump_request(); } send_response(); break; case DEBUG_OFF: if (debug) debug--; netperf_response.content.response_type = DEBUG_OK; send_response(); /* +SAF why??? */ if (!debug) fclose(where); break; case CPU_CALIBRATE: netperf_response.content.response_type = CPU_CALIBRATE; temp_rate = calibrate_local_cpu(0.0); bcopy((char *)&temp_rate, (char *)netperf_response.content.test_specific_data, sizeof(temp_rate)); if (debug) { fprintf(where,"netserver: sending CPU information:"); fprintf(where,"rate is %g\n",temp_rate); fflush(where); } /* we need the cpu_start, cpu_stop in the looper case to kill the */ /* child proceses raj 7/95 */ #ifdef USE_LOOPER cpu_start(1); cpu_stop(1,&temp_rate); #endif /* USE_LOOPER */ send_response(); break; case DO_TCP_STREAM: recv_tcp_stream(); break; case DO_TCP_MAERTS: recv_tcp_maerts(); break; case DO_TCP_RR: recv_tcp_rr(); break; case DO_TCP_CRR: recv_tcp_conn_rr(); break; case DO_TCP_CC: recv_tcp_cc(); break; #ifdef DO_1644 case DO_TCP_TRR: recv_tcp_tran_rr(); break; #endif /* DO_1644 */ #ifdef DO_NBRR case DO_TCP_NBRR: recv_tcp_nbrr(); break; #endif /* DO_NBRR */ case DO_UDP_STREAM: recv_udp_stream(); break; case DO_UDP_RR: recv_udp_rr(); break; #ifdef WANT_DLPI case DO_DLPI_CO_RR: recv_dlpi_co_rr(); break; case DO_DLPI_CL_RR: recv_dlpi_cl_rr(); break; case DO_DLPI_CO_STREAM: recv_dlpi_co_stream(); break; case DO_DLPI_CL_STREAM: recv_dlpi_cl_stream(); break; #endif /* WANT_DLPI */ #ifdef WANT_UNIX case DO_STREAM_STREAM: recv_stream_stream(); break; case DO_STREAM_RR: recv_stream_rr(); break; case DO_DG_STREAM: recv_dg_stream(); break; case DO_DG_RR: recv_dg_rr(); break; #endif /* WANT_UNIX */ #ifdef WANT_XTI case DO_XTI_TCP_STREAM: recv_xti_tcp_stream(); break; case DO_XTI_TCP_RR: recv_xti_tcp_rr(); break; case DO_XTI_UDP_STREAM: recv_xti_udp_stream(); break; case DO_XTI_UDP_RR: recv_xti_udp_rr(); break; #endif /* WANT_XTI */ #ifdef DO_DNS case DO_DNS_RR: recv_dns_rr(); break; #endif /* DO_DNS */ #ifdef WANT_SCTP case DO_SCTP_STREAM: recv_sctp_stream(); break; case DO_SCTP_STREAM_MANY: recv_sctp_stream_1toMany(); break; case DO_SCTP_RR: recv_sctp_rr(); break; case DO_SCTP_RR_MANY: recv_sctp_rr_1toMany(); break; #endif default: fprintf(where,"unknown test number %d\n", netperf_request.content.request_type); fflush(where); netperf_response.content.serv_errno=998; send_response(); break; } } }
void process_requests() { float temp_rate; while (1) { if (recv_request() == 0) return; if (debug) dump_request(); switch (netperf_request.content.request_type) { case DEBUG_ON: netperf_response.content.response_type = DEBUG_OK; if (!debug) debug++; dump_request(); send_response(); break; case DEBUG_OFF: if (debug) debug--; netperf_response.content.response_type = DEBUG_OK; fclose(where); send_response(); break; case CPU_CALIBRATE: netperf_response.content.response_type = CPU_CALIBRATE; temp_rate = calibrate_local_cpu(0.0); bcopy((char *)&temp_rate, (char *)netperf_response.content.test_specific_data, sizeof(temp_rate)); if (debug) { fprintf(where,"netserver: sending CPU information:"); fprintf(where,"rate is %g\n",temp_rate); fflush(where); } /* we need the cpu_start, cpu_stop in the looper case to kill the */ /* child proceses raj 7/95 */ cpu_start(1); cpu_stop(1,&temp_rate); send_response(); break; case DO_TCP_STREAM: recv_tcp_stream(); break; case DO_TCP_RR: recv_tcp_rr(); break; case DO_TCP_CRR: recv_tcp_conn_rr(); break; case DO_TCP_CC: recv_tcp_cc(); break; #ifdef DO_1644 case DO_TCP_TRR: recv_tcp_tran_rr(); break; #endif /* DO_1644 */ #ifdef DO_NBRR case DO_TCP_NBRR: recv_tcp_nbrr(); break; #endif /* DO_NBRR */ case DO_UDP_STREAM: recv_udp_stream(); break; case DO_UDP_RR: recv_udp_rr(); break; #ifdef DO_DLPI case DO_DLPI_CO_RR: recv_dlpi_co_rr(); break; case DO_DLPI_CL_RR: recv_dlpi_cl_rr(); break; case DO_DLPI_CO_STREAM: recv_dlpi_co_stream(); break; case DO_DLPI_CL_STREAM: recv_dlpi_cl_stream(); break; #endif /* DO_DLPI */ #ifdef DO_UNIX case DO_STREAM_STREAM: recv_stream_stream(); break; case DO_STREAM_RR: recv_stream_rr(); break; case DO_DG_STREAM: recv_dg_stream(); break; case DO_DG_RR: recv_dg_rr(); break; #endif /* DO_UNIX */ #ifdef DO_FORE case DO_FORE_STREAM: recv_fore_stream(); break; case DO_FORE_RR: recv_fore_rr(); break; #endif /* DO_FORE */ #ifdef DO_HIPPI case DO_HIPPI_STREAM: recv_hippi_stream(); break; case DO_HIPPI_RR: recv_hippi_rr(); break; #endif /* DO_HIPPI */ #ifdef DO_XTI case DO_XTI_TCP_STREAM: recv_xti_tcp_stream(); break; case DO_XTI_TCP_RR: recv_xti_tcp_rr(); break; case DO_XTI_UDP_STREAM: recv_xti_udp_stream(); break; case DO_XTI_UDP_RR: recv_xti_udp_rr(); break; #endif /* DO_XTI */ #ifdef DO_LWP case DO_LWPSTR_STREAM: recv_lwpstr_stream(); break; case DO_LWPSTR_RR: recv_lwpstr_rr(); break; case DO_LWPDG_STREAM: recv_lwpdg_stream(); break; case DO_LWPDG_RR: recv_lwpdg_rr(); break; #endif /* DO_LWP */ #ifdef DO_IPV6 case DO_TCPIPV6_STREAM: recv_tcpipv6_stream(); break; case DO_TCPIPV6_RR: recv_tcpipv6_rr(); break; case DO_TCPIPV6_CRR: recv_tcpipv6_conn_rr(); break; case DO_UDPIPV6_STREAM: recv_udpipv6_stream(); break; case DO_UDPIPV6_RR: recv_udpipv6_rr(); break; #endif /* DO_IPV6 */ default: fprintf(where,"unknown test number %d\n", netperf_request.content.request_type); fflush(where); netperf_response.content.serv_errno=998; send_response(); break; } } }
void process_requests() { float temp_rate; if (debug) { fprintf(where, "%s: enter\n", __FUNCTION__); fflush(where); } while (1) { if (recv_request() == 0) return; switch (netperf_request.content.request_type) { case DEBUG_ON: netperf_response.content.response_type = DEBUG_OK; if (!suppress_debug) { debug++; if (debug == 1) { /* we just flipped-on debugging, dump the request because recv_request/recv_request_n will not have dumped it as its dump_request() call is conditional on debug being set. raj 2011-07-08 */ dump_request(); } } send_response(); break; case DEBUG_OFF: if (debug) debug--; netperf_response.content.response_type = DEBUG_OK; send_response(); /* we used to take the trouble to close the debug file, but SAF asked a good question when he asked "Why?" and since I cannot think of a good reason, I have removed the code. raj 2011-07-08 */ break; case DO_SYSINFO: { char *delims[4]; int i; delims[0] = strdup("|"); delims[1] = strdup(","); delims[2] = strdup("_"); delims[3] = strdup(";"); netperf_response.content.response_type = SYSINFO_RESPONSE; for (i = 0; i < 4; i++) { if ((!strstr(local_sysname,delims[i])) && (!strstr(local_release,delims[i])) && (!strstr(local_machine,delims[i])) && (!strstr(local_version,delims[i]))) { snprintf((char *)netperf_response.content.test_specific_data, sizeof(netperf_response.content.test_specific_data), "%c%s%c%s%c%s%c%s", delims[i][0], local_sysname, delims[i][0], local_release, delims[i][0], local_machine, delims[i][0], local_version); break; } } if (i == 4) { /* none of the delimiters were unique, use the last one of course, the last one is not i but i-1 */ i -= 1; snprintf((char *)netperf_response.content.test_specific_data, sizeof(netperf_response.content.test_specific_data), "%c%s%c%s%c%s%c%s", delims[i][0], "NoDelimUnique", delims[i][0], "NoDelimUnique", delims[i][0], "NoDelimUnique", delims[i][0], "NoDelimUnique"); } send_response_n(0); break; } case CPU_CALIBRATE: netperf_response.content.response_type = CPU_CALIBRATE; temp_rate = calibrate_local_cpu(0.0); bcopy((char *)&temp_rate, (char *)netperf_response.content.test_specific_data, sizeof(temp_rate)); bcopy((char *)&lib_num_loc_cpus, (char *)netperf_response.content.test_specific_data + sizeof(temp_rate), sizeof(lib_num_loc_cpus)); if (debug) { fprintf(where, "netserver: sending CPU information: rate is %g num cpu %d\n", temp_rate, lib_num_loc_cpus); fflush(where); } /* we need the cpu_start, cpu_stop in the looper case to kill the child proceses raj 7/95 */ #ifdef USE_LOOPER cpu_start(1); cpu_stop(1,&temp_rate); #endif /* USE_LOOPER */ send_response(); break; case DO_TCP_STREAM: recv_tcp_stream(); break; case DO_TCP_MAERTS: recv_tcp_maerts(); break; case DO_TCP_RR: recv_tcp_rr(); break; case DO_TCP_CRR: recv_tcp_conn_rr(); break; case DO_TCP_CC: recv_tcp_cc(); break; #ifdef DO_1644 case DO_TCP_TRR: recv_tcp_tran_rr(); break; #endif /* DO_1644 */ #ifdef DO_NBRR case DO_TCP_NBRR: recv_tcp_nbrr(); break; #endif /* DO_NBRR */ case DO_UDP_STREAM: recv_udp_stream(); break; case DO_UDP_RR: recv_udp_rr(); break; #ifdef WANT_DLPI case DO_DLPI_CO_RR: recv_dlpi_co_rr(); break; case DO_DLPI_CL_RR: recv_dlpi_cl_rr(); break; case DO_DLPI_CO_STREAM: recv_dlpi_co_stream(); break; case DO_DLPI_CL_STREAM: recv_dlpi_cl_stream(); break; #endif /* WANT_DLPI */ #ifdef WANT_UNIX case DO_STREAM_STREAM: recv_stream_stream(); break; case DO_STREAM_RR: recv_stream_rr(); break; case DO_DG_STREAM: recv_dg_stream(); break; case DO_DG_RR: recv_dg_rr(); break; #endif /* WANT_UNIX */ #ifdef WANT_XTI case DO_XTI_TCP_STREAM: recv_xti_tcp_stream(); break; case DO_XTI_TCP_RR: recv_xti_tcp_rr(); break; case DO_XTI_UDP_STREAM: recv_xti_udp_stream(); break; case DO_XTI_UDP_RR: recv_xti_udp_rr(); break; #endif /* WANT_XTI */ #ifdef WANT_SCTP case DO_SCTP_STREAM: recv_sctp_stream(); break; case DO_SCTP_STREAM_MANY: recv_sctp_stream_1toMany(); break; case DO_SCTP_RR: recv_sctp_rr(); break; case DO_SCTP_RR_MANY: recv_sctp_rr_1toMany(); break; #endif #ifdef WANT_SDP case DO_SDP_STREAM: recv_sdp_stream(); break; case DO_SDP_MAERTS: recv_sdp_maerts(); break; case DO_SDP_RR: recv_sdp_rr(); break; #endif #ifdef WANT_OMNI case DO_OMNI: recv_omni(); break; #endif default: fprintf(where,"unknown test number %d\n", netperf_request.content.request_type); fflush(where); netperf_response.content.serv_errno=998; send_response(); break; } } }