Exemple #1
0
/*
 * Called everytime new data is read from any of the connections
 * that are part of a pipe.
 */
static int
ktunnel_pipe_data(struct netbuf *nb)
{
	struct connection	*src = nb->owner;
	struct connection	*dst = src->hdlr_extra;

	printf("received %d bytes on pipe %p (-> %p)\n", nb->s_off, src, dst);

	net_send_queue(dst, nb->buf, nb->s_off, NULL, NETBUF_LAST_CHAIN);
	net_send_flush(dst);
	net_recv_reset(src, NETBUF_SEND_PAYLOAD_MAX, ktunnel_pipe_data);

	return (KORE_RESULT_OK);
}
Exemple #2
0
/*
 * Called whenever data is available that must be piped through
 * to the paired connection. (client<>backend or backend<>client).
 */
int
pipe_data(struct netbuf *nb)
{
	struct connection	*src = nb->owner;
	struct connection	*dst = src->hdlr_extra;

	/* Flush data out towards destination. */
	net_send_queue(dst, nb->buf, nb->s_off);
	net_send_flush(dst);

	/* Reset read for source. */
	net_recv_reset(src, NETBUF_SEND_PAYLOAD_MAX, pipe_data);

	return (KORE_RESULT_OK);
}
Exemple #3
0
void
db_results(struct kore_pgsql *pgsql, struct connection *c)
{
	char		*name;
	int		i, rows;

	rows = kore_pgsql_ntuples(pgsql);
	for (i = 0; i < rows; i++) {
		name = kore_pgsql_getvalue(pgsql, i, 0);
		net_send_queue(c, name, strlen(name));
	}

	net_send_flush(c);
	kore_pgsql_continue(pgsql);
}
Exemple #4
0
/*
 * This function is called everytime we get up to 128 bytes of data.
 * The connection can be found under nb->owner.
 * The data received can be found under nb->buf.
 * The length of the received data can be found under s_off.
 */
int
connection_recv_data(struct netbuf *nb)
{
	struct connection	*c = (struct connection *)nb->owner;

	kore_log(LOG_NOTICE, "%p: received %u bytes", c, nb->s_off);

	/* We will just dump these back to the client. */
	net_send_queue(c, nb->buf, nb->s_off);
	net_send_flush(c);

	/* Now reset the receive command for the next one. */
	net_recv_reset(c, 128, connection_recv_data);

	return (KORE_RESULT_OK);
}