예제 #1
0
static int ncp_do_request(struct ncp_server *server, int size,
		void* reply, int max_reply_size)
{
	int result;

	if (server->lock == 0) {
		printk(KERN_ERR "ncpfs: Server not locked!\n");
		return -EIO;
	}
	if (!ncp_conn_valid(server)) {
		return -EIO;
	}
#ifdef CONFIG_NCPFS_PACKET_SIGNING
	if (server->sign_active)
	{
		sign_packet(server, &size);
	}
#endif /* CONFIG_NCPFS_PACKET_SIGNING */
	result = do_ncp_rpc_call(server, size, reply, max_reply_size);

	DDPRINTK(KERN_DEBUG "do_ncp_rpc_call returned %d\n", result);

	if (result < 0) {
		/* There was a problem with I/O, so the connections is
		 * no longer usable. */
		ncp_invalidate_conn(server);
	}
	return result;
}
예제 #2
0
파일: sock.c 프로젝트: xricson/knoppix
static void ncptcp_start_request(struct ncp_server *server, struct ncp_request_reply *req) {
    size_t signlen;
    struct ncp_request_header* h;

    req->tx_ciov = req->tx_iov;
    h = req->tx_iov[1].iov_base;
    ncp_init_header(server, req, h);
    signlen = sign_packet(server, req->tx_iov[1].iov_base + sizeof(struct ncp_request_header) - 1,
                          req->tx_iov[1].iov_len - sizeof(struct ncp_request_header) + 1,
                          cpu_to_be32(req->tx_totallen + 24), req->sign + 4) + 16;

    req->sign[0] = htonl(NCP_TCP_XMIT_MAGIC);
    req->sign[1] = htonl(req->tx_totallen + signlen);
    req->sign[2] = htonl(NCP_TCP_XMIT_VERSION);
    req->sign[3] = htonl(req->datalen + 8);
    req->tx_iov[0].iov_base = req->sign;
    req->tx_iov[0].iov_len = signlen;
    req->tx_iovlen += 1;
    req->tx_totallen += signlen;

    server->tx.creq = req;
    __ncptcp_try_send(server);
}
예제 #3
0
파일: sock.c 프로젝트: xricson/knoppix
static void ncpdgram_start_request(struct ncp_server *server, struct ncp_request_reply *req) {
    size_t signlen;
    struct ncp_request_header* h;

    req->tx_ciov = req->tx_iov + 1;

    h = req->tx_iov[1].iov_base;
    ncp_init_header(server, req, h);
    signlen = sign_packet(server, req->tx_iov[1].iov_base + sizeof(struct ncp_request_header) - 1,
                          req->tx_iov[1].iov_len - sizeof(struct ncp_request_header) + 1,
                          cpu_to_le32(req->tx_totallen), req->sign);
    if (signlen) {
        req->tx_ciov[1].iov_base = req->sign;
        req->tx_ciov[1].iov_len = signlen;
        req->tx_iovlen += 1;
        req->tx_totallen += signlen;
    }
    server->rcv.creq = req;
    server->timeout_last = server->m.time_out;
    server->timeout_retries = server->m.retry_count;
    ncpdgram_send(server->ncp_sock, req);
    mod_timer(&server->timeout_tm, jiffies + server->m.time_out);
}
예제 #4
0
파일: sock.c 프로젝트: JBTech/ralink_rt5350
static int ncp_do_request(struct ncp_server *server, int size,
		void* reply, int max_reply_size)
{
	struct file *file;
	struct socket *sock;
	int result;

	if (server->lock == 0) {
		printk(KERN_ERR "ncpfs: Server not locked!\n");
		return -EIO;
	}
	if (!ncp_conn_valid(server)) {
		return -EIO;
	}
#ifdef CONFIG_NCPFS_PACKET_SIGNING
	if (server->sign_active)
	{
		sign_packet(server, &size);
	}
#endif /* CONFIG_NCPFS_PACKET_SIGNING */
	file = server->ncp_filp;
	sock = &file->f_dentry->d_inode->u.socket_i;
	/* N.B. this isn't needed ... check socket type? */
	if (!sock) {
		printk(KERN_ERR "ncp_rpc_call: socki_lookup failed\n");
		result = -EBADF;
	} else {
		mm_segment_t fs;
		sigset_t old_set;
		unsigned long mask, flags;

		spin_lock_irqsave(&current->sigmask_lock, flags);
		old_set = current->blocked;
		if (current->flags & PF_EXITING)
			mask = 0;
		else
			mask = sigmask(SIGKILL);
		if (server->m.flags & NCP_MOUNT_INTR) {
			/* FIXME: This doesn't seem right at all.  So, like,
			   we can't handle SIGINT and get whatever to stop?
			   What if we've blocked it ourselves?  What about
			   alarms?  Why, in fact, are we mucking with the
			   sigmask at all? -- r~ */
			if (current->sig->action[SIGINT - 1].sa.sa_handler == SIG_DFL)
				mask |= sigmask(SIGINT);
			if (current->sig->action[SIGQUIT - 1].sa.sa_handler == SIG_DFL)
				mask |= sigmask(SIGQUIT);
		}
		siginitsetinv(&current->blocked, mask);
		recalc_sigpending(current);
		spin_unlock_irqrestore(&current->sigmask_lock, flags);
		
		fs = get_fs();
		set_fs(get_ds());

		if (sock->type == SOCK_STREAM)
			result = do_ncp_tcp_rpc_call(server, size, reply, max_reply_size);
		else
			result = do_ncp_rpc_call(server, size, reply, max_reply_size);

		set_fs(fs);

		spin_lock_irqsave(&current->sigmask_lock, flags);
		current->blocked = old_set;
		recalc_sigpending(current);
		spin_unlock_irqrestore(&current->sigmask_lock, flags);
	}

	DDPRINTK("do_ncp_rpc_call returned %d\n", result);

	if (result < 0) {
		/* There was a problem with I/O, so the connections is
		 * no longer usable. */
		ncp_invalidate_conn(server);
	}
	return result;
}