Example #1
0
int main()
{
    DCMF_Messager_initialize();

    init();

    barrier_init(DCMF_DEFAULT_GLOBALBARRIER_PROTOCOL);

    posix_memalign((void **) &source, 16, MAX_MSG_SIZE_LOCAL);
    posix_memalign((void **) &target, 16, MAX_MSG_SIZE_LOCAL);

    send_init(DCMF_EAGER_SEND_PROTOCOL, DCMF_TORUS_NETWORK);

    barrier();

    send_remoteadvance();

    barrier();

    if (myrank == 0)
    {
        printf("[%d] Benchmark Complete \n", myrank);
        fflush(stdout);
    }

    memregion_finalize();

    DCMF_Messager_finalize();

    return 0;
}
Example #2
0
static int init_tcp_copy()
{
	select_sever_set_callback(dispose_event);
	raw_sock=init_raw_socket();
	if(raw_sock!=-1)
	{
		select_sever_add(raw_sock);
		/*init sending info*/
		send_init();
#if (MULTI_THREADS)  
		pthread_t thread;
		pthread_mutex_init(&mutex,NULL);
		pthread_cond_init(&full,NULL);
		pthread_cond_init(&empty,NULL);
		pthread_create(&thread,NULL,dispose,NULL);
#endif
		//add a connection to the tested server for exchanging infomation
		add_msg_connetion(local_port,remote_ip,remote_port);
		logInfo(LOG_NOTICE,"add a tunnel for exchanging information:%u",
				ntohs(remote_port));

		return SUCCESS;
	}else
	{
		return FAILURE;
	}

}
Example #3
0
//static int run(int argc, char **argv)
int ibrdma_send(char* host, char* port, void* data, uint64_t size)
{
  
  struct addrinfo *addr;
  struct rdma_cm_id *cmid= NULL;
  struct rdma_event_channel *ec = NULL;
  struct rdma_conn_param cm_params;
  TEST_NZ(getaddrinfo(host, port, NULL, &addr));
  TEST_Z(ec = rdma_create_event_channel());
  TEST_NZ(rdma_create_id(ec, &cmid, NULL, RDMA_PS_TCP));
  TEST_NZ(rdma_resolve_addr(cmid, NULL, addr->ai_addr, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ADDR_RESOLVED));
  freeaddrinfo(addr);
  build_connection(cmid);
  TEST_NZ(rdma_resolve_route(cmid, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ROUTE_RESOLVED));
  build_params(&cm_params);
  TEST_NZ(rdma_connect(cmid, &cm_params));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ESTABLISHED));
  on_connect(cmid->context);

  /* Init MSG send to start RDMA*/
  init_tfile(data,  size);
  send_init(cmid->context);
  /*----------------------------*/

  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_DISCONNECTED));
  rdma_destroy_id(cmid);
  rdma_destroy_event_channel(ec);

  return 0;
}
Example #4
0
int main()
{
    infra_init();
    os_init();

    receive_init(fn_receive, fn_flash_receive_sink);
    collect_init(fn_collect, fn_flash_collect_sink, dt_collect);
    send_init(fn_send, fn_flash_receive_source, fn_flash_collect_source, dt_send);
    os_run();

    return 0;
}
Example #5
0
void eth_init( Hubyte *src )
{
    Huint i;

    // Copy the source mac address
    for( i = 0; i < ETH_MAC_SIZE; i++ )  eth_mac[i] = src[i];
    
    // Initialize the sending functionality
    //send_init( "eth1" );
    send_init( "en0" );

    // Initialize the receiving functionality
    //recv_init( "eth1" );
    recv_init( "en0" );
}
Example #6
0
RESPONSECODE IFDHPowerICC(DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength)
{
    int i;

    for (i = 0; i < MAX_LUNS; i++)
        if (luns[i].fd != -1 && luns[i].lun == Lun)
            if (Action == IFD_POWER_UP || Action == IFD_RESET) {
                if (*AtrLength >= luns[i].atr_len) {
                    memcpy(Atr, luns[i].atr, luns[i].atr_len);
                    *AtrLength = luns[i].atr_len;
                }
                send_init(&luns[i]);
                return IFD_SUCCESS;
            }

    fprintf(stderr, "spiceccid %s unsupported: Lun %ld, Action %ld\n", __FUNCTION__, Lun, Action);
    return IFD_ERROR_NOT_SUPPORTED;
}
Example #7
0
int main(int argc, char **argv)
{
	if(argc != 3)
	{
		printf("Usage ./<bin> <server-ip> <server-port>\n");
		return 1;
	}

	strcpy(server_addr, argv[1]);
	server_port = atoi(argv[2]);

	my_port = ws_listen(dummy_recv_cb, 0);
	send_init();

	while(loop());

	return 0;
}
Example #8
0
int main()
{
	os_init();

 	collect_init("", "", 0);
	q_next();
	q_next();
	q_next();

 	receive_init("", "");
	receive_input();	
	q_next();

 	send_init("", "", "", 0);
	q_next();
	q_next();
	q_next();
	q_next();

	return 0;	
}
Example #9
0
int main()
{
    DCMF_Messager_initialize();

    init();

    source = (char *) malloc(MAX_MSG_SIZE * ITERATIONS * 2);
    target = (char *) malloc(MAX_MSG_SIZE * ITERATIONS * 2);
    target_index = 0;

    barrier_init(DCMF_DEFAULT_GLOBALBARRIER_PROTOCOL);

    allreduce_init(DCMF_DEFAULT_GLOBALALLREDUCE_PROTOCOL);

    ack_control_init(DCMF_DEFAULT_CONTROL_PROTOCOL, DCMF_DEFAULT_NETWORK);

    send_init(DCMF_DEFAULT_SEND_PROTOCOL, DCMF_TORUS_NETWORK);

    rcb_send_init(DCMF_DEFAULT_SEND_PROTOCOL, DCMF_TORUS_NETWORK);

    barrier();

    send_localvsremote();

    barrier();

    if (myrank == 0)
    {
        printf("[%d] Benchmark Complete \n", myrank);
        fflush(stdout);
    }

    DCMF_Messager_finalize();

    return 0;
}
Example #10
0
/* Initiate tcpcopy client */
int tcp_copy_init(cpy_event_loop_t *event_loop)
{
    int                    i;
#if (TCPCOPY_OFFLINE)
    char                  *pcap_file;
    char                   ebuf[PCAP_ERRBUF_SIZE];
#endif
    uint16_t               online_port, target_port;
    uint32_t               target_ip;
    ip_port_pair_mapping_t *pair;
    ip_port_pair_mapping_t **mappings;
    cpy_event_t            *raw_socket_event;

    /* keep it temporarily */
    select_server_set_callback(dispose_event);

    /* Init session table*/
    init_for_sessions();
    localhost = inet_addr("127.0.0.1"); 

    /* Init output raw socket info */
    send_init();
    /* Add connections to the tested server for exchanging info */
    mappings = clt_settings.transfer.mappings;
    for(i = 0; i < clt_settings.transfer.num; i++){
        pair = mappings[i];
        online_port = pair->online_port;
        target_ip   = pair->target_ip;
        target_port = pair->target_port;
        if(address_add_msg_conn(event_loop, online_port, target_ip, 
                clt_settings.srv_port))
        {
            return FAILURE;
        }
        log_info(LOG_NOTICE, "add a tunnel for exchanging info:%u",
                ntohs(target_port));
    }
    
#if (!TCPCOPY_OFFLINE)
    /* Init input raw socket info */
    raw_sock = init_input_raw_socket();
#endif
    if(raw_sock != -1){
        /* Add the input raw socket to select */
        raw_socket_event = cpy_event_create(raw_sock, dispose_event_wrapper,
                                           NULL);
        if (raw_socket_event == NULL) {
            return FAILURE;
        }

        if (cpy_event_add(event_loop, raw_socket_event, CPY_EVENT_READ)
                == CPY_EVENT_ERROR)
        {
            log_info(LOG_ERR, "add raw socket(%d) to event loop failed.",
                     raw_socket_event->fd);
            return FAILURE;
        }

        /* Init output raw socket info */
        send_init();
        /* Add connections to the tested server for exchanging info */
        mappings = clt_settings.transfer.mappings;
        for(i = 0; i < clt_settings.transfer.num; i++){
            pair = mappings[i];
            online_port = pair->online_port;
            target_ip   = pair->target_ip;
            target_port = pair->target_port;

            if (address_add_msg_conn(event_loop, online_port, target_ip, 
                                     clt_settings.srv_port) == -1)
            {
                return FAILURE;
            }

            log_info(LOG_NOTICE, "add a tunnel for exchanging info:%u",
                    ntohs(target_port));
        }
        return SUCCESS;
    }else{
#if (TCPCOPY_OFFLINE)
        select_offline_set_callback(send_packets_from_pcap);
        pcap_file = clt_settings.pcap_file;
        if(pcap_file != NULL){
            if ((pcap = pcap_open_offline(pcap_file, ebuf)) == NULL){
                log_info(LOG_ERR, "open %s" , ebuf);
                fprintf(stderr, "open %s\n", ebuf);
                return FAILURE;

            }else{
                gettimeofday(&base_time, NULL);
                log_info(LOG_NOTICE, "open pcap success:%s", pcap_file);
                log_info(LOG_NOTICE, "send the first packets here");
                send_packets_from_pcap(1);
            }
        }else{
            return FAILURE;
        }
#else
        return FAILURE;
#endif
    }

    return SUCCESS;
}
Example #11
0
/* Initiate udpcopy client */
int udp_copy_init(tc_event_loop_t *event_loop)
{
#if (UDPCOPY_OFFLINE)
    char                   *pcap_file, ebuf[PCAP_ERRBUF_SIZE];
#endif
    tc_event_t             *raw_socket_event;

    /* keep it temporarily */
    select_server_set_callback(dispose_event);

    localhost = inet_addr("127.0.0.1"); 

    /* Init output raw socket info */
    send_init();

#if (!UDPCOPY_OFFLINE)
    /* Init input raw socket info */
    raw_sock = init_input_raw_socket();
#endif
    if (raw_sock != -1){
        /* Add the input raw socket to select */
        raw_socket_event = tc_event_create(raw_sock, dispose_event_wrapper,
                                           NULL);
        if (raw_socket_event == NULL) {
            return FAILURE;
        }

        if (tc_event_add(event_loop, raw_socket_event, TC_EVENT_READ)
                == TC_EVENT_ERROR)
        {
            log_info(LOG_ERR, "add raw socket(%d) to event loop failed.",
                     raw_socket_event->fd);
            return FAILURE;
        }

        /* Init output raw socket info */
        send_init();
        return SUCCESS;
    }else{
#if (UDPCOPY_OFFLINE)
        select_offline_set_callback(send_packets_from_pcap);
        pcap_file = clt_settings.pcap_file;
        if (pcap_file != NULL){
            if ((pcap = pcap_open_offline(pcap_file, ebuf)) == NULL){
                log_info(LOG_ERR, "open %s" , ebuf);
                fprintf(stderr, "open %s\n", ebuf);
                return FAILURE;

            }else{
                gettimeofday(&base_time, NULL);
                log_info(LOG_NOTICE, "open pcap success:%s", pcap_file);
                log_info(LOG_NOTICE, "send the first packets here");
                send_packets_from_pcap(1);
            }
        }else{
            return FAILURE;
        }
#else
        return FAILURE;
#endif
    }

    return SUCCESS;
}
Example #12
0
int main(int argc, char *argv[])
{
   /*
    * Alloc the global structures
    * We can access these structs via the macro in ec_globals.h
    */
        
   globals_alloc();
  
   GBL_PROGRAM = strdup(EC_PROGRAM);
   GBL_VERSION = strdup(EC_VERSION);
   SAFE_CALLOC(GBL_DEBUG_FILE, strlen(EC_PROGRAM) + strlen(EC_VERSION) + strlen("_debug.log") + 1, sizeof(char));
   sprintf(GBL_DEBUG_FILE, "%s%s_debug.log", GBL_PROGRAM, EC_VERSION);
   
   DEBUG_INIT();
   DEBUG_MSG("main -- here we go !!");

   /* initialize the filter mutex */
   filter_init_mutex();
   
   /* register the main thread as "init" */
   ec_thread_register(EC_PTHREAD_SELF, "init", "initialization phase");
   
   /* activate the signal handler */
   signal_handler();
   
   /* ettercap copyright */
   fprintf(stdout, "\n" EC_COLOR_BOLD "%s %s" EC_COLOR_END " copyright %s %s\n\n", 
         GBL_PROGRAM, GBL_VERSION, EC_COPYRIGHT, EC_AUTHORS);
   
   /* getopt related parsing...  */
   parse_options(argc, argv);

   /* check the date */
   time_check();

   /* load the configuration file */
   load_conf();
   
   /* 
    * get the list of available interfaces 
    * 
    * this function will not return if the -I option was
    * specified on command line. it will instead print the
    * list and exit
    */
   capture_getifs();
   
   /* initialize the user interface */
   ui_init();
   
   /* initialize libpcap */
   capture_init();

   /* initialize libnet (the function contain all the checks) */
   send_init();
 
   /* get hardware infos */
   get_hw_info();
 
   /* 
    * always disable the kernel ip forwarding (except when reading from file).
    * the forwarding will be done by ettercap.
    */
   if (!GBL_OPTIONS->read && !GBL_OPTIONS->unoffensive && !GBL_OPTIONS->only_mitm)
      disable_ip_forward();
      
   /* binds ports and set redirect for ssl wrapper */
   if (!GBL_OPTIONS->read && !GBL_OPTIONS->unoffensive && !GBL_OPTIONS->only_mitm && GBL_SNIFF->type == SM_UNIFIED)
      ssl_wrap_init();
   
   /* 
    * drop root privileges 
    * we have alread opened the sockets with high privileges
    * we don't need any more root privs.
    */
   drop_privs();

/***** !! NO PRIVS AFTER THIS POINT !! *****/

   /* load all the plugins */
   plugin_load_all();

   /* print how many dissectors were loaded */
   conf_dissectors();
   
   /* load the mac-fingerprints */
   manuf_init();

   /* load the tcp-fingerprints */
   fingerprint_init();
   
   /* load the services names */
   services_init();
   
   /* load http known fileds for user/pass */
   http_fields_init();

   /* set the encoding for the UTF-8 visualization */
   set_utf8_encoding(GBL_CONF->utf8_encoding);
  
   /* print all the buffered messages */
   if (GBL_UI->type == UI_TEXT)
      USER_MSG("\n");
   
   ui_msg_flush(MSG_ALL);

/**** INITIALIZATION PHASE TERMINATED ****/
   
   /* 
    * we are interested only in the mitm attack i
    * if entered, this function will not return...
    */
   if (GBL_OPTIONS->only_mitm)
      only_mitm();
   
   /* create the dispatcher thread */
   ec_thread_new("top_half", "dispatching module", &top_half, NULL);

   /* this thread becomes the UI then displays it */
   ec_thread_register(EC_PTHREAD_SELF, GBL_PROGRAM, "the user interface");
   ui_start();

/******************************************** 
 * reached only when the UI is shutted down 
 ********************************************/

   /* flush the exit message */
   ui_msg_flush(MSG_ALL);
   
   /* stop the mitm attack */
   mitm_stop();

   /* terminate the sniffing engine */
   EXECUTE(GBL_SNIFF->cleanup);
   
   /* kill all the running threads but the current */
   ec_thread_kill_all();
  
   /* clean up the UI */
   ui_cleanup();

   return 0;
}
Example #13
0
int main(int argc, void* argv[])
{
    DCMF_Configure_t config;

    config.thread_level = DCMF_THREAD_MULTIPLE;

    DCMF_Messager_initialize();

    DCMF_Messager_configure(&config, &config);

    init();

    if (nranks != (THREAD_NUM + 1))
    {
        printf("This test requires only %d processes \n", (THREAD_NUM + 1));
        fflush(stdout);
        return -1;
    }

    barrier_init(DCMF_DEFAULT_GLOBALBARRIER_PROTOCOL);

    control_init(DCMF_DEFAULT_CONTROL_PROTOCOL, DCMF_DEFAULT_NETWORK);

    memregion_init(LOCAL_MAX_BUF_SIZE * THREAD_NUM);

    get_init(DCMF_DEFAULT_PUT_PROTOCOL, DCMF_TORUS_NETWORK);

    source = (char *) malloc(LOCAL_MAX_BUF_SIZE * THREAD_NUM);
    target = (char *) malloc(LOCAL_MAX_BUF_SIZE * THREAD_NUM);

    send_init(DCMF_DEFAULT_SEND_PROTOCOL, DCMF_TORUS_NETWORK);

    int status;
    long i;

    if (myrank == 0)
    {

        pthread_t threads[THREAD_NUM];
        pthread_barrier_init(&ptbarrier, NULL, THREAD_NUM);
        pthread_barrier_init(&ptbarrier1, NULL, THREAD_NUM);

        for (i = 0; i < THREAD_NUM; i++)
        {
            pthread_create(&threads[i], NULL, mrate_test, (void *) i);
        }

        for (i = 0; i < THREAD_NUM; i++)
        {
            pthread_join(threads[i], (void *) &status);
        }
    }
    else
    {

        snd_rcv_active += LOCAL_ITERATIONS;
        while (snd_rcv_active > 0)
            DCMF_Messager_advance();

    }

    barrier();

    DCMF_Messager_finalize();

    if (myrank == 0)
    {
        printf("Benchmark Complete \n");
        fflush(stdout);
    }

    return (0);
}