예제 #1
0
int
packet_read_seqnr(u_int32_t *seqnr)
{
	u_char type;
	int r;

	if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)) != 0)
		sshpkt_fatal(active_state, __func__, r);
	return type;
}
예제 #2
0
int
ssh_dispatch_run(struct ssh *ssh, int mode, volatile sig_atomic_t *done)
{
	int r;
	u_char type;
	u_int32_t seqnr;

	for (;;) {
		if (mode == DISPATCH_BLOCK) {
			r = ssh_packet_read_seqnr(ssh, &type, &seqnr);
			if (r != 0)
				return r;
		} else {
			r = ssh_packet_read_poll_seqnr(ssh, &type, &seqnr);
			if (r != 0)
				return r;
			if (type == SSH_MSG_NONE)
				return 0;
		}
		if (type > 0 && type < DISPATCH_MAX &&
		    ssh->dispatch[type] != NULL) {
			if (ssh->skip_packets) {
				debug2("skipped packet (type %u)", type);
				ssh->skip_packets--;
				continue;
			}
			r = (*ssh->dispatch[type])(type, seqnr, ssh);
			if (r != 0)
				return r;
		} else {
			r = sshpkt_disconnect(ssh,
			    "protocol error: rcvd type %d", type);
			if (r != 0)
				return r;
			return SSH_ERR_DISCONNECTED;
		}
		if (done != NULL && *done)
			return 0;
	}
}