dag_config_get_card_fd(3)

NAME
dag_config_get_card_fd - retrieve the file descriptor associated with a Configuration and Status API DAG card reference

SYNOPSIS
#include "dagapi.h "

int
dag_config_get_card_fd(dag_card_ref_t card);

DESCRIPTION
dag_config_get_card_fd returns the file descriptor associated with a reference to a card.

RETURN VALUE
A file descriptor corresponding to the specified card that can be used with routines in the Capture API, or -1 if card is invalid.

NOTES
The relationship between a DAG card file descriptor (stored in a variable of type int) and a reference to a DAG card (stored in a variable of type dag_card_ref_t) parallels the relationship between POSIX file descriptors (also ints) and C Standard Library streams (the FILE* type). POSIX provides a routine for opening a file descriptor:

    int
    open(const char * path, int flags, mode_t mode);

and the C Standard Library provides a routine for opening a stream:

    FILE*
    fopen(const char * restrict path, const char * restrict mode);

The file descriptor is the low-level object, while the stream provides additional features such as buffering. Auxiliary routines allow a stream to be wrapped around an existing file descriptor:

    FILE*
    fdopen(int fildes, const char* mode);

and the file descriptor underlying a stream to be recovered:

    int
    fileno(FILE* stream);

In a similar manner, the file descriptor is the lower-level way to refer to a DAG card while the card reference provides additional features such as component access and configuration. So we have the following correspondence between the file descriptor/stream APIs and the file descriptor/card reference APIs:

    *   A POSIX file descriptor corresponds to a DAG file descriptor.

    *   A stream (FILE*) corresponds to a card reference (dag_card_ref_t).

    *   open(2) corresponds to dag_open(3).

    *   fopen(3) corresponds to dag_config_init(3).

    *   fdopen(3) corresponds to dag_config_init_fd(3).

    *   fileno(3) corresponds to dag_config_get_card_fd(3).

EXAMPLE
To use the Capture API followed by the Configuration and Status API:

    int dagfd;
    dag_card_ref_t card;
    dagfd = dag_open("/dev/dag0");
    /* Perform capture operations. */
    card = dag_config_init_fd(dagfd);
    /* Perform configuration operations. */

To use the Configuration and Status API followed by the Capture API:

    int dagfd;
    dag_card_ref_t card;
    card = dag_config_init("/dev/dag0");
    /* Perform configuration operations. */
    dagfd = dag_config_get_card_fd(card);
    /* Perform capture operations.
     * Note that dag_open() should not be called.
     */

SEE ALSO
dagapi(3), dag_config_init(3),dag_config_init_fd(3), dag_open(3), fdopen(3), fileno(3), fopen(3), open(2).

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.