Exemplo n.º 1
0
void transfer_test_data(bool is_sender,
                        const std::string& pattern,
                        const std::string& topology) {
    if (pattern == "pipeline") {
        if (topology == "one_to_many" && is_sender) {
            nano::push send_queue("tcp://127.0.0.1:5555", nano::topology::one_to_many);
            send_queue.send<std::vector<std::string>>({"test", "vector"});
        } else if (topology == "one_to_many" && !is_sender) {
            nano::pull receive_queue("tcp://127.0.0.1:5555", nano::topology::one_to_many);
            auto received = receive_queue.receive<std::vector<std::string>>();
            for (auto& test_data:received) {
                LOG(INFO) << "received: " << test_data;
            }
        } else if (topology == "many_to_one" && is_sender) {
            nano::push send_queue("tcp://127.0.0.1:5555", nano::topology::many_to_one);
            send_queue.send<std::vector<std::string>>({"test", "vector"});
        } else if (topology == "one_to_many" && !is_sender) {
            nano::pull receive_queue("tcp://127.0.0.1:5555", nano::topology::many_to_one);
            auto received = receive_queue.receive<std::vector<std::string>>();
            for (auto& test_data:received) {
                LOG(INFO) << "received: " << test_data;
            }
        }
    }

}
Exemplo n.º 2
0
int 
switch_rep (/*Change to specified repertoire.
	             Switching is done by sending
		     a Write Attribute NDQ.
		   */
    int rep_num
)
{

	TEXT_UPDATE ud;

	if(rep_num == 1) transparent = 0;
	else transparent = 1;

	bzero ((char *) &ud, sizeof ud);
	ud.echo_sw = cur_emode;
	ud.type_sw =  DISPLAY_OBJ;
	ud.updates.do_list.do_name = my_displayobj;
	ud.updates.do_list.do_type = DO_ATTR;
	ud.updates.do_list.do_cmd.wrt_attrib.attr_id = 0;
	ud.updates.do_list.do_cmd.wrt_attrib.attr_val = rep_num; /*Rep Number*/
	ud.updates.do_list.do_cmd.wrt_attrib.attr_ext = 2; /*Modal Extent*/
	send_queue(ud);
	vtsend();
}
Exemplo n.º 3
0
/* ARGSUSED */
int 
vt_ayt (	/*Send Are You There*/
    char **vec
)
{

	TEXT_UPDATE ud;
	char mask;
	char image;

	if(!telnet_profile) {
		advise(LLOG_NOTICE,NULLCP,  "not using TELNET profile");
		return NOTOK;
	}
	mask = AYT_OBJ;
	kb_image ^= AYT_OBJ;	/*Can only be called by User side*/
	image = kb_image;
	bzero ((char *) &ud, sizeof ud);
	ud.echo_sw = cur_emode;
	ud.type_sw = CTRL_OBJ;
	ud.updates.co_list.co_name = my_signal_obj;
	ud.updates.co_list.co_type = 1;	/*Boolean Update*/
	ud.updates.co_list.co_cmd.bool_update.value = &image;
	ud.updates.co_list.co_cmd.bool_update.val_count = KB_SIZE;
	ud.updates.co_list.co_cmd.bool_update.mask = &mask;
	ud.updates.co_list.co_cmd.bool_update.mask_count = KB_SIZE;
	send_queue(ud);
	vtsend();

	return OK;
}
Exemplo n.º 4
0
/* ARGSUSED */
int 
vt_break (char **vec)
{
#ifdef VT_BREAK
	if(!do_break) {
		advise(LLOG_NOTICE,NULLCP,"VT-BREAK Functional Unit Not Chosen");
		return OK;
	}
	tmode(2);
	vt_clr_obj();	/*Initialize all control objects*/
	vbrkreq();
#else
	TEXT_UPDATE ud;

	mask = BRK_OBJ;
	kb_image ^= BRK_OBJ;	/*Can Only be called by User side*/
	image = kb_image;

	bzero ((char *) ud, sizeof *ud);
	ud.echo_sw = cur_emode;
	ud.type_sw = CTRL_OBJ;
	ud.updates.co_list.co_name = my_signal_obj;
	ud.updates.co_list.co_type = 1;	/*Boolean Update*/
	ud.updates.co_list.co_cmd.bool_update.value = &image;
	ud.updates.co_list.co_cmd.bool_update.val_count = KB_SIZE;
	ud.updates.co_list.co_cmd.bool_update.mask = &mask;
	ud.updates.co_list.co_cmd.bool_update.mask_count = KB_SIZE;
	send_queue(ud);
	vtsend();
#endif

	return OK;
}
Exemplo n.º 5
0
int 
vt_interrupt (void) {	/*Toggle Bit 1 of DI/KB control object*/

	TEXT_UPDATE ud;
	char int_mask;
	char image;

	int_mask = IP_OBJ;
	if(my_right == INITIATOR) {
		kb_image ^= IP_OBJ;
		image = kb_image;
	} else {
		di_image ^= IP_OBJ;	/*Toggle the Interrupt Process bit*/
		image = di_image;
	}
	bzero ((char *) &ud, sizeof ud);
	ud.echo_sw = cur_emode;
	ud.type_sw = CTRL_OBJ;
	ud.updates.co_list.co_name = my_signal_obj;
	ud.updates.co_list.co_type = 1;	/*Boolean Update*/
	ud.updates.co_list.co_cmd.bool_update.value = &image;
	ud.updates.co_list.co_cmd.bool_update.val_count = KB_SIZE;
	ud.updates.co_list.co_cmd.bool_update.mask = &int_mask;
	ud.updates.co_list.co_cmd.bool_update.mask_count = KB_SIZE;
	send_queue(ud);
}
Exemplo n.º 6
0
        void
        dgram::request(id_ptr id)
        {
                _id i;

                i.id = id;

                if (m_requesting.find(i) == m_requesting.end()) {
                        try {
                                m_peers.get_addr(id); // throw std::out_of_range
                                send_queue(id);
                        } catch (std::out_of_range) {
                                // request
                                if (m_dtun.is_enabled()) {
                                        request_func func;

                                        func.p_dgram = this;
                                        func.dst     = id;

                                        m_requesting.insert(i);
                                        m_dtun.request(*id, func);
                                } else {
                                        find_node_func func;

                                        func.p_dgram = this;
                                        func.dst     = id;

                                        m_requesting.insert(i);
                                        m_dht.find_node(*id, func);
                                }
                        }
                }
        }
Exemplo n.º 7
0
vt_newline() {	/*Produce Newline update*/

	TEXT_UPDATE ud;

	bzero ((char *) &ud, sizeof ud);
	ud.echo_sw = cur_emode;
	ud.type_sw = DISPLAY_OBJ;
	ud.updates.do_list.do_name = my_displayobj;
	ud.updates.do_list.do_type = DO_NEXT_X;		/*Next X-Array*/
	send_queue(ud);
}
Exemplo n.º 8
0
int 
vt_line_erase (void) {	/*Erase full x-array & pointer to x = 1*/

	TEXT_UPDATE ud;

	bzero ((char *) &ud, sizeof ud);
	ud.echo_sw = cur_emode;
	ud.type_sw = DISPLAY_OBJ;
	ud.updates.do_list.do_name = my_displayobj;
	ud.updates.do_list.do_type = DO_ERASE;
	ud.updates.do_list.do_cmd.erase.start_erase.ptr_type = 3; /*Start X*/
	ud.updates.do_list.do_cmd.erase.end_erase.ptr_type = 6; /*End X*/
	ud.updates.do_list.do_cmd.erase.erase_attr = 0;

	send_queue(ud);

	ud.updates.do_list.do_type = DO_PTR_ABS;
	ud.updates.do_list.do_cmd.ptr_abs.ptr_type = 3; /*Start X*/

	send_queue(ud);
}
Exemplo n.º 9
0
int 
vt_char_erase (void) {	/*Pointer Relative (x=x-1) & erase current*/

	TEXT_UPDATE ud;

	bzero ((char *) &ud, sizeof ud);
	ud.echo_sw = cur_emode;
	ud.type_sw = DISPLAY_OBJ;
	ud.updates.do_list.do_name = my_displayobj;
	ud.updates.do_list.do_type = DO_PTR_REL;
	ud.updates.do_list.do_cmd.ptr_rel.x_true = 1;
	ud.updates.do_list.do_cmd.ptr_rel.y_true = 0;
	ud.updates.do_list.do_cmd.ptr_rel.z_true = 0;
	ud.updates.do_list.do_cmd.ptr_rel.x_value = -1;

	send_queue(ud);

	ud.updates.do_list.do_type = DO_ERASE;
	ud.updates.do_list.do_cmd.erase.start_erase.ptr_type = 0; /*Current*/
	ud.updates.do_list.do_cmd.erase.end_erase.ptr_type = 0; /*Current*/
	ud.updates.do_list.do_cmd.erase.erase_attr = 0;

	send_queue(ud);
}
Exemplo n.º 10
0
void read_wifi(struct params *p)
{
	static char *buf = 0;
	static int buflen = 4096;
	struct ieee80211_frame *wh;
	int rc;

	if (!buf) {
		buf = (char*) malloc(buflen);
		if (!buf)
			err(1, "malloc()");
	}
	
	rc = sniff(p->rx, buf, buflen);
	if (rc == -1)
		err(1, "sniff()");

	wh = get_wifi(buf, &rc);
	if (!wh)
		return;

	/* relayed macast */
	if (frame_type(wh, IEEE80211_FC0_TYPE_DATA,
		       IEEE80211_FC0_SUBTYPE_DATA) &&
	    (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) &&
	    (memcmp(wh->i_addr2, p->ap, 6) == 0) &&
	    (memcmp(wh->i_addr1, p->mcast, 5) == 0) &&
	    (memcmp(p->mac, wh->i_addr3, 6) == 0)) {
		got_mcast(p, wh, rc);
		return;
	}

	/* data */
	if (frame_type(wh, IEEE80211_FC0_TYPE_DATA,
		       IEEE80211_FC0_SUBTYPE_DATA)) {
		if (!wanted(p, wh, rc))
			return;
		
		enque(p, &buf, wh, rc);
		if (p->state == S_START)
			send_queue(p);
		return;
	}
}
Exemplo n.º 11
0
void own(struct params *p)
{
	struct timeval tv;
	struct timeval *to = NULL;
	fd_set fds;
	int tout = 10*1000;

	if (p->state == S_WAIT_RELAY) {
		int el;

		/* check timeout */
		if (gettimeofday(&tv, NULL) == -1)
			err(1, "gettimeofday()");
	
		el = elapsed(&p->last, &tv);

		/* timeout */
		if (el >= tout) {
			if (p->q && p->q->live) {
				send_queue(p);
				el = 0;
			} else {
				p->state = S_START;
				return;
			}
		}
		el = tout - el;
		tv.tv_sec = el/1000/1000;
		tv.tv_usec = el - tv.tv_sec*1000*1000;
		to = &tv;
	}

	FD_ZERO(&fds);
	FD_SET(p->rx, &fds);

	if (select(p->rx+1, &fds, NULL, NULL, to) == -1)
		err(1, "select()");

	if (FD_ISSET(p->rx, &fds))
		read_wifi(p);
}
Exemplo n.º 12
0
int 
vt_set_nego (	/*Update NA/NI control object as in image*/
    int image,
    int mask
)
{

	TEXT_UPDATE ud;
	char e_image;

	bzero ((char *) &ud, sizeof ud);
	ud.echo_sw = cur_emode;
	ud.type_sw = CTRL_OBJ;
	ud.updates.co_list.co_name = my_echo_obj;
	ud.updates.co_list.co_type = 1;			/*Boolean*/
	e_image = image;
	ud.updates.co_list.co_cmd.bool_update.value = &e_image;
	ud.updates.co_list.co_cmd.bool_update.val_count = NA_SIZE;
	ud.updates.co_list.co_cmd.bool_update.mask = &mask;
	ud.updates.co_list.co_cmd.bool_update.mask_count = NA_SIZE;
	send_queue(ud);
	vtsend();	/*Since we're bypassing normal keyboard entry*/
}