Ejemplo n.º 1
0
static void *cygwin_reader(void *arg)
{
	struct priv_cygwin *priv = arg;
	unsigned char buf[2048];
	int len;
	struct rx_info ri;

	while (priv->pc_running) {
		/* read one packet */
		len = cygwin_read_packet(priv, buf, sizeof(buf), &ri);
		if (len == -1)
			break;

		/* len */
		len += sizeof(ri);
		if (write(priv->pc_pipe[1], &len, sizeof(len)) != sizeof(len))
			break;
		len -= sizeof(ri);

		/* ri */
		if (write(priv->pc_pipe[1], &ri, sizeof(ri)) != sizeof(ri))
			break;

		/* packet */
		if (write(priv->pc_pipe[1], buf, len) != len)
			break;
	}

	priv->pc_running = -1;
	return NULL;
}
Ejemplo n.º 2
0
static void * cygwin_reader(void * arg)
{
	struct priv_cygwin * priv = arg;
	unsigned char buf[2048];
	int len;
	struct rx_info ri;

	while (priv->pc_running)
	{
		/* read one packet */

		/* a potential problem: the cygwin_read_packet will never return
		 * if there no packet sniffered, so the thread cannot be closed
		 * correctly.
		 */
		len = cygwin_read_packet(priv, buf, sizeof(buf), &ri);
		if (len == -1) break;

		/* len */
		len += sizeof(ri);
		if (write(priv->pc_pipe[1], &len, sizeof(len)) != sizeof(len)) break;
		len -= sizeof(ri);

		/* ri */
		if (write(priv->pc_pipe[1], &ri, sizeof(ri)) != sizeof(ri)) break;

		/* packet */
		if (write(priv->pc_pipe[1], buf, len) != len) break;
	}

	priv->pc_running = -1;
	return NULL;
}