Logo Search packages:      
Sourcecode: uapevent version File versions  Download package

int read_event ( int  sk_fd,
unsigned char *  buffer,
int  timeout,
struct nlmsghdr *  nlh,
struct msghdr *  msg 
)

Configure and read event data from netlink socket.

Parameters:
sk_fdNetlink socket handler
bufferPointer to the data buffer
timeoutSocket listen timeout value
nlhPointer to netlink message header
msgPointer to message header
Returns:
Number of bytes read or UAP_FAILURE

Definition at line 686 of file uapevent.c.

References read_event_netlink_socket(), terminate_flag, UAP_FAILURE, and UAP_RECV_WAIT_DEFAULT.

Referenced by main().

{
    struct timeval tv;
    fd_set rfds;
    int ret = UAP_FAILURE;

    /* Setup read fds */
    FD_ZERO(&rfds);
    FD_SET(sk_fd, &rfds);

    /* Initialize timeout value */
    if (timeout != 0)
        tv.tv_sec = timeout;
    else
        tv.tv_sec = UAP_RECV_WAIT_DEFAULT;
    tv.tv_usec = 0;

    /* Wait for reply */
    ret = select(sk_fd + 1, &rfds, NULL, NULL, &tv);
    if (ret == -1) {
        /* Error */
        terminate_flag++;
        return UAP_FAILURE;
    } else if (!ret) {
        /* Timeout. Try again */
        return UAP_FAILURE;
    }
    if (!FD_ISSET(sk_fd, &rfds)) {
        /* Unexpected error. Try again */
        return UAP_FAILURE;
    }

    /* Success */
    ret = read_event_netlink_socket(sk_fd, buffer, nlh, msg);
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index