CNDP  22.08.0
cne_event.h File Reference
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
#include <errno.h>
#include <bsd/string.h>
#include <cne_common.h>

Go to the source code of this file.

Data Structures

struct  cne_ev_handle
 
struct  cne_ev_read_buffer
 

Typedefs

typedef void(* cne_ev_callback_fn) (void *cb_arg)
 
typedef void(* cne_ev_unregister_callback_fn) (struct cne_ev_handle *ev_handle, void *cb_arg)
 

Functions

CNDP_API int cne_ev_callback_register (const struct cne_ev_handle *ev_handle, cne_ev_callback_fn cb_fn, void *cb_arg)
 
CNDP_API int cne_ev_callback_unregister (const struct cne_ev_handle *ev_handle, cne_ev_callback_fn cb_fn, void *cb_arg)
 
CNDP_API int cne_ev_callback_unregister_pending (const struct cne_ev_handle *ev_handle, cne_ev_callback_fn cb_fn, void *cb_arg, cne_ev_unregister_callback_fn ucb_fn)
 

Detailed Description

Event monitoring Helpers in CNE

Definition in file cne_event.h.

Typedef Documentation

◆ cne_ev_callback_fn

typedef void(* cne_ev_callback_fn) (void *cb_arg)

Function to be registered for the specific interrupt

Parameters
cb_argaddress of parameter for callback.

Definition at line 45 of file cne_event.h.

◆ cne_ev_unregister_callback_fn

typedef void(* cne_ev_unregister_callback_fn) (struct cne_ev_handle *ev_handle, void *cb_arg)

Function to call after a callback is unregistered. Can be used to close fd and free cb_arg.

Parameters
ev_handlePointer to the event handle.
cb_argaddress of parameter for callback.

Definition at line 56 of file cne_event.h.

Function Documentation

◆ cne_ev_callback_register()

CNDP_API int cne_ev_callback_register ( const struct cne_ev_handle ev_handle,
cne_ev_callback_fn  cb_fn,
void *  cb_arg 
)

It registers the callback for the specific event. Multiple callbacks can be registered at the same time.

Parameters
ev_handlePointer to the event handle.
cb_fncallback address.
cb_argaddress of parameter for callback.
Returns
  • On success, zero.
  • On failure, a negative value.

◆ cne_ev_callback_unregister()

CNDP_API int cne_ev_callback_unregister ( const struct cne_ev_handle ev_handle,
cne_ev_callback_fn  cb_fn,
void *  cb_arg 
)

It unregisters the callback for the specific event. Multiple callbacks can be registered at the same time.

Parameters
ev_handlePointer to the event handle.
cb_fncallback address.
cb_argaddress of parameter for callback.
Returns
  • On success, zero.
  • On failure, a negative value.

◆ cne_ev_callback_unregister_pending()

CNDP_API int cne_ev_callback_unregister_pending ( const struct cne_ev_handle ev_handle,
cne_ev_callback_fn  cb_fn,
void *  cb_arg,
cne_ev_unregister_callback_fn  ucb_fn 
)

Unregister the callback according to the specified event handle, after it's no longer active. Fail if source is not active.

Parameters
ev_handlepointer to the event handle.
cb_fncallback address.
cb_argaddress of parameter for callback, (void *)-1 means to remove all registered which has the same callback address.
ucb_fncallback to call before cb is unregistered (optional). can be used to close fd and free cb_arg.
Returns
  • On success, return the number of callback entities marked for remove.
  • On failure, a negative value.