dag_configure(3)

NAME
dag_configure - configure an Endace DAG card for operation

SYNOPSIS
#include "dagapi.h "

int dag_configure(int dagfd, char* params);

DESCRIPTION
dag_configure configures a card so that a capture/transmit session can be carried out. params is a string of configuration words separated by whitespace.

At present the following options are implemented by dag_configure:

slen=N
    Set packet capture length (also known as the snap length) to N bytes. N will be rounded down to the nearest multiple of four. Packets longer than N bytes will be truncated to N.

varlen
    Set capture record mode to variable length. Packets shorter than the snap length will produce short records.

novarlen
    Set capture record mode to fixed length. Packets shorter than the snap length will be padded to the snap length.

fixed
    Same as novarlen.

ncells=N
    Only for ATM capture mode on the DAG 3.5. N is in [0,15] and specifies the number of cells to return from the start of each AAL5 frame. The DAG 3.5 is capable of tracking the state of many VPI/VCI pairs at once. If N is zero then all cells are captured, including OAM and RM cells (which would otherwise be dropped).

(no)lcells
    Only for ATM capture mode on the DAG 3.5 when ncells > 0. If set, the last cell of the AAL5 frame containing the AAL5 trailer will always be captured. For example, if ncells = 3 and lcell is set then the first, second, third and seventh cells will be captured from a seven-cell AAL5 frame.

RETURN VALUE
On success dag_configure returns zero, otherwise it returns -1 with errno set appropriately.

ERRORS

EBADF
    dagfd is an invalid file descriptor.

EINVAL
    params contained an invalid token.

EIO fatal internal error.

ENODEV
    no such device.

Additional error codes as for lseek(2), read(2), fork(2), execvp(2), execlp(2), execve(2), and wait(2).

EXAMPLE
	const char* dagname = "/dev/dag0";
	const char* config = "slen=1536 varlen";
	int stream = 0;
	int flags = 0;
	int extra_window_size = 4*1024*1024;
	int mindata = 32*1024;
	struct timeval poll;
	struct timeval maxwait;
	int dagfd;
	int result;
	/* open DAG, configure, and attach to stream 0 (receive) */
	dagfd = dag_open(dagname);
	if (-1 == dagfd)
	{
		panic("dag_open(%s): %s
", dagname, strerror(errno));
	}

	result = dag_configure(dagfd, config);
	if (-1 == result)
	{
		panic("dag_configure(%s, %s): %s
", dagname, config, strerror(errno));
	}

	result = dag_attach_stream(dagfd, stream, flags, extra_window_size);
	if (-1 == result)
	{
		panic("dag_attach_stream(%s): %s
", dagname, strerror(errno));
	}

	result = dag_start_stream(dagfd, stream);
	if (-1 == result)
	{
		panic("dag_start_stream(%s): %s
", dagname, strerror(errno));
	}

	/* Initialise DAG polling parameters. */
	timerclear(&maxwait);
	maxwait.tv_usec = 100 * 1000; /* 100ms timeout. */
	timerclear(&poll);
	poll.tv_usec = 10 * 1000;     /* 10ms poll interval. */

	/* 32kB minimum data to return. */
	dag_set_stream_poll(dagfd, stream, mindata, &maxwait, &poll);

	/* Main packet processing loop. */
	while (1 == gRun)
	{
		dag_record_t* rec = (dag_record_t*) dag_rx_stream_next_record(dagfd, stream);
		if (NULL != rec)
		{
			int length = ntohs(rec->rlen);

			process_packet(rec, length); /* Packet processing routine. */
		}
		else
		{
			if (errno != EAGAIN)
			{
				panic("dag_rx_stream_next_record(%s): %s
", dagname, strerror(errno));
			}
		}
	}

	/* Finished; stop capture, detach from stream and close. */
	dag_stop_stream(dagfd, stream);
	dag_detach_stream(dagfd, stream);
	dag_close(dagfd);

SEE ALSO
dag_open(3), dag_close(3).

BUGS
Report bugs to <support@endace.com>.

LAST UPDATED
$Author: koryn $
$Revision: 2474 $
$Date: 2005-11-10 11:13:19 +1300 (Thu, 10 Nov 2005) $

COPYRIGHT
(c) 2004-2005 Endace Technology, Hamilton, New Zealand. All Rights Reserved.