示例#1
0
    bool read_pkt(buf_ptr &buf)
    {
        buf_ptr buf_in = super::buffer();
        super::rlnc_hdr_reserve(buf_in);

        if (!super::read_pkt(buf_in))
            return false;

        switch (super::rlnc_hdr_type(buf_in)) {
            case super::rlnc_ack:
                process_ack(buf_in);
                return false;

            case super::rlnc_stop:
                std::cout << "enc stopped" << std::endl;
                m_stopped = true;
                return false;

            default:
                std::cout << "unexpected packet: "
                          << super::rlnc_hdr_type(buf_in) << std::endl;
                break;
        }

        return true;
    }
示例#2
0
文件: detour.c 项目: jeramirez/base
/*
 * this function tells the client to go into 'character at a time mode',
 * meaning every keystroke will be transferred in a packet.
 */
static int
negotiate_telnet_options(int client)
{
	unsigned char	suppress_go_ahead[] = { IAC, WILL, TELOPT_SGA };
	unsigned char	ack_suppress_go_ahead[] = { IAC, DO, TELOPT_SGA };

	unsigned char	will_echo[] = { IAC, WILL, TELOPT_ECHO };
	unsigned char	ack_will_echo[] = { IAC, DO, TELOPT_ECHO };

	if (write(client, suppress_go_ahead, 
			sizeof(suppress_go_ahead)) == -1) {

		fprintf(stderr, "negotiate_telnet_options:write:suppress_go_ahead:errno (%d)\n", errno);

		return(-1);
	}

	if (process_ack(client, ack_suppress_go_ahead,
			sizeof(ack_suppress_go_ahead)) == -1) {

		fprintf(stderr, "negotiate_telnet_options:process_ack:suppress_go_ahead\n");

		return(-1);
	}

	if (write(client, will_echo, 
			sizeof(will_echo)) == -1) {

		fprintf(stderr, "negotiate_telnet_options:write:suppress_go_ahead:errno (%d)\n", errno);

		return(-1);
	}

	if (process_ack(client, ack_will_echo, sizeof(ack_will_echo)) == -1) {
		fprintf(stderr,
			"negotiate_telnet_options:process_ack:will_echo\n");

		return(-1);
	}

	return(0);
}
示例#3
0
static void handle_response (CcnetProcessor *processor,
                             char *code, char *code_msg,
                             char *content, int clen)
{
    SeafileSendblockV2Proc *proc = (SeafileSendblockV2Proc *)processor;
    USE_PRIV;

    if (proc->tx_task->state != TASK_STATE_NORMAL) {
        g_debug ("Task not running, send-block proc exits.\n");
        ccnet_processor_done (processor, TRUE);
        return;
    }

    switch (priv->tdata->state) {
    case REQUEST_SENT:
        if (memcmp (code, SC_OK, 3) == 0) {
            send_block_list (processor);
            priv->tdata->state = BLOCKLIST_SENT;
            return;
        }
        break;
    case BLOCKLIST_SENT:
        if (memcmp (code, SC_BBITMAP, 3) == 0) {
            process_block_bitmap (processor, content, clen);
            return;
        }
        break;
    case GET_PORT:
        if (memcmp (code, SC_SEND_PORT, 3) == 0) {
            get_port (processor, content, clen);
            return;
        }
        break;
    case READY:
        if (memcmp (code, SC_ACK, 3) == 0) {
            process_ack (processor, content, clen);
            return;
        }
    }

    g_warning ("Bad response: %s %s.\n", code, code_msg);
    if (memcmp (code, SC_ACCESS_DENIED, 3) == 0)
        transfer_task_set_error (proc->tx_task, TASK_ERR_ACCESS_DENIED);
    ccnet_processor_done (processor, FALSE);
}
示例#4
0
文件: recv.c 项目: constroy/uOSPF
void *recv_loop(void *p) {
	uint8_t buf[BUFFER_SIZE];
	interface *iface;
	ospf_header *ospfhdr;
	neighbor *nbr;
	in_addr_t src;
	while (*(int *)p) {
		iface = recv_ospf(sock, buf, BUFFER_SIZE, &src);
		ospfhdr = (ospf_header *)(buf + sizeof(struct iphdr));
		/* check if the packet is from myself */
		if (ospfhdr->router_id == myid) continue;
		for (nbr = iface->nbrs; nbr; nbr = nbr->next)
			if (ospfhdr->router_id == nbr->router_id) break;
		switch (ospfhdr->type) {
			case OSPF_TYPE_HELLO: process_hello(iface, nbr, ospfhdr, src); break;
			case OSPF_TYPE_DD: process_dd(iface, nbr, ospfhdr); break;
			case OSPF_TYPE_LSR: process_lsr(nbr, ospfhdr);break;
			case OSPF_TYPE_LSU: process_lsu(iface->a, nbr, ospfhdr);break;
			case OSPF_TYPE_LSACK: process_ack(nbr, ospfhdr);break;
			default: break;
		}
	}
	return NULL;
}
		void ReliabilitySystem::processAck( unsigned int ack, unsigned int ack_bits )
		{
			process_ack( ack, ack_bits, pendingAckQueue, ackedQueue, acks, acked_packets, rtt, max_sequence );
		}