Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
Classes | Typedefs | Enumerations | Functions
interface.h File Reference

Interface base class. More...

#include <stdbool.h>
#include <hicn/facemgr/loop.h>
Include dependency graph for interface.h:

Go to the source code of this file.

Classes

struct  interface_ops_t
 
struct  interface_s
 

Typedefs

typedef int(* interface_cb_t) (facemgr_t *facemgr, interface_cb_type_t type, void *data)
 
typedef struct interface_s interface_t
 
typedef int(* interface_fd_callback_t) (interface_t *interface, int fd, void *unused)
 

Enumerations

enum  interface_cb_type_t {
  INTERFACE_CB_TYPE_REGISTER_FD, INTERFACE_CB_TYPE_UNREGISTER_FD, INTERFACE_CB_TYPE_RAISE_EVENT, INTERFACE_CB_TYPE_REGISTER_TIMER,
  INTERFACE_CB_TYPE_UNREGISTER_TIMER
}
 

Functions

int interface_register (const interface_ops_t *ops)
 Registers a new interface type. More...
 
int interface_unregister_all ()
 Unregister all interface types.
 
interface_tinterface_create (const char *name, const char *type)
 Create a new instance of an interface of a given type. More...
 
void interface_free (interface_t *interface)
 Free an interface instance. More...
 
void interface_set_callback (interface_t *interface, void *callback_owner, interface_cb_t callback)
 
int interface_initialize (interface_t *interface, void *cfg)
 
int interface_finalize (interface_t *interface)
 
int interface_on_event (interface_t *interface, struct facelet_s *facelet)
 
int interface_callback (interface_t *interface, interface_cb_type_t type, void *data)
 Raises a facelet event to the face manager. More...
 
int interface_raise_event (interface_t *interface, facelet_t *facelet)
 
int interface_register_fd (interface_t *interface, int fd, void *data)
 
int interface_unregister_fd (interface_t *interface, int fd)
 
int interface_register_timer (interface_t *interface, unsigned delay_ms, interface_fd_callback_t callback, void *data)
 Registers a timer event. More...
 
int interface_unregister_timer (interface_t *interface, int fd)
 Unregisters a timer event. More...
 

Detailed Description

Interface base class.

Interfaces are the priviledged way to extend the functionalities of the face manager. They both provide input and/or output functionality to allow for several components to interoperate, respectively by raising/receiving events about changes in the underlying network.

All communication happens through base operations (create, delete, etc.) over a generic face abstraction.

Function Documentation

◆ interface_callback()

int interface_callback ( interface_t interface,
interface_cb_type_t  type,
void *  data 
)

Raises a facelet event to the face manager.

Parameters
[in]interface- Interface that raised the event (or NULL if it was created but the face manager itself, or is a joined event)
[in]facelet- Facelet to communicate with the event
Returns
Error code

◆ interface_create()

interface_t* interface_create ( const char *  name,
const char *  type 
)

Create a new instance of an interface of a given type.

Parameters
[in]name- Name of the newly create interface instance.
[in]type- Name of the interface type to create.
Returns
A a pointer to the newly created instance of the requested type, or NULL in case of failure.

◆ interface_free()

void interface_free ( interface_t interface)

Free an interface instance.

Parameters
[in]interface- Pointer to the instance to free.

◆ interface_register()

int interface_register ( const interface_ops_t ops)

Registers a new interface type.

Parameters
[in]ops- Virtual function table representing the interface operations.
Returns
Flag indicating the success (FACEMGR_SUCCESS=0), or failure (any other value) of the operation.

◆ interface_register_timer()

int interface_register_timer ( interface_t interface,
unsigned  delay_ms,
interface_fd_callback_t  callback,
void *  data 
)

Registers a timer event.

Parameters
[in]interface- Pointer to the interface responsible for the timer
[in]delay_ms- Delay in milliseconds between timer events (first occurence happends after this delay)
[in]callback- Callback function to be triggered
[in]data- User data
Returns
A positive value uniquely identifying the timer, or -1 in case of error

◆ interface_unregister_timer()

int interface_unregister_timer ( interface_t interface,
int  fd 
)

Unregisters a timer event.

Parameters
[in]interface- Pointer to the interface responsible for the timer
[in]fd- Timer identifier
Returns
0 in case of success, -1 otherwise