anjay
Loading...
Searching...
No Matches
nidd.h File Reference
#include <anjay/core.h>
#include <avsystem/commons/avs_defs.h>

Go to the source code of this file.

Data Structures

struct  anjay_nidd_driver_struct
 

Typedefs

typedef int anjay_nidd_driver_recv_t(anjay_nidd_driver_t *driver, size_t *out_bytes_received, void *out_message, size_t size, avs_time_monotonic_t deadline)
 
typedef int anjay_nidd_driver_can_recv_t(anjay_nidd_driver_t *driver)
 
typedef int anjay_nidd_driver_send_t(anjay_nidd_driver_t *driver, const void *message, size_t size)
 
typedef avs_errno_t anjay_nidd_driver_error_t(anjay_nidd_driver_t *driver)
 
typedef int anjay_nidd_driver_connect_t(anjay_nidd_driver_t *driver)
 
typedef int anjay_nidd_driver_disconnect_t(anjay_nidd_driver_t *driver)
 
typedef int anjay_nidd_driver_system_descriptor_t(anjay_nidd_driver_t *driver, const void **out)
 
typedef void anjay_nidd_driver_free_t(anjay_nidd_driver_t *driver)
 
typedef int anjay_nidd_driver_outgoing_mtu_t(anjay_nidd_driver_t *driver, size_t *out_mtu)
 
typedef int anjay_nidd_driver_incoming_mtu_t(anjay_nidd_driver_t *driver, size_t *out_mtu)
 

Functions

void anjay_nidd_driver_cleanup (anjay_nidd_driver_t **driver)
 

Typedef Documentation

◆ anjay_nidd_driver_can_recv_t

typedef int anjay_nidd_driver_can_recv_t(anjay_nidd_driver_t *driver)

Checks if it is currently possible to receive any data from the driver.

Parameters
driverDevice driver context to operate on.
Returns
1 if something can be read, 0 if nothing can be read, negative value in case of error. Driver errno MUST be set to a non-zero value if the function fails.

◆ anjay_nidd_driver_connect_t

typedef int anjay_nidd_driver_connect_t(anjay_nidd_driver_t *driver)

Sets up the NIDD connection on the underlying device.

Parameters
driverDevice driver context to operate on.
Returns
0 on success, negative value in case of an error. Driver errno MUST be set to a non-zero value if the function fails.

◆ anjay_nidd_driver_disconnect_t

typedef int anjay_nidd_driver_disconnect_t(anjay_nidd_driver_t *driver)

Unsets the NIDD connection on the underlying device.

Parameters
driverDevice driver context to operate on.
Returns
0 on success, negative value in case of an error. Driver errno MUST be set to a non-zero value if the function fails.

◆ anjay_nidd_driver_error_t

typedef avs_errno_t anjay_nidd_driver_error_t(anjay_nidd_driver_t *driver)

Obtains error code of the last operation if it failed.

NOTE: AVS_ENODEV is reserved for signalling a loss-of-carrier condition that shall NOT be treated as fatal. For this one special error code, errors while handling incoming requests will NOT trigger connection closure (and subsequent retry and/or rebootstrap attempts) as all other errors will.

Parameters
driverDevice driver context to operate on.
Returns
last errno code.

◆ anjay_nidd_driver_free_t

typedef void anjay_nidd_driver_free_t(anjay_nidd_driver_t *driver)

Cleanups the device driver, freeing all used resources.

Parameters
driverDevice driver context to operate on.

◆ anjay_nidd_driver_incoming_mtu_t

typedef int anjay_nidd_driver_incoming_mtu_t(anjay_nidd_driver_t *driver, size_t *out_mtu)

Obtains the MTU of incoming NIDD packets.

NOTE: You may specify only one of the outgoing_mtu and incoming_mtu callbacks and leave the other as NULL. In that case that one MTU value will be used for both directions.

Parameters
driverDevice driver context to operate on.
out_mtuPointer where the MTU shall be stored.
Returns
0 on success, negative value in case of an error.

◆ anjay_nidd_driver_outgoing_mtu_t

typedef int anjay_nidd_driver_outgoing_mtu_t(anjay_nidd_driver_t *driver, size_t *out_mtu)

Obtains the MTU of outgoing NIDD packets.

NOTE: You may specify only one of the outgoing_mtu and incoming_mtu callbacks and leave the other as NULL. In that case that one MTU value will be used for both directions.

Parameters
driverDevice driver context to operate on.
out_mtuPointer where the MTU shall be stored.
Returns
0 on success, negative value in case of an error.

◆ anjay_nidd_driver_recv_t

typedef int anjay_nidd_driver_recv_t(anjay_nidd_driver_t *driver, size_t *out_bytes_received, void *out_message, size_t size, avs_time_monotonic_t deadline)

Attempts to receive entire message over NIDD to out_message.

NOTE: If the device has no message to return within the timeout, it MUST not block, return negative value and set driver errno to AVS_ETIMEDOUT.

NOTE: If the out_message is too small to hold an entire message, the function MUST fail with driver errno set to AVS_EMSGSIZE.

Parameters
driverDevice driver context to operate on.
out_bytes_receivedPointer to a variable that, on successful exit, MUST be set to the number of bytes successfully read into out_message .
out_messageMessage buffer to write to.
sizeMaximum message size in bytes.
deadlineDeadline of the operation.
Returns
0 on success, negative value in case of error. Driver errno MUST be set to a non-zero value if the function fails.

◆ anjay_nidd_driver_send_t

typedef int anjay_nidd_driver_send_t(anjay_nidd_driver_t *driver, const void *message, size_t size)

Sends entire message over NIDD, stored in buffer.

Parameters
driverDevice driver context to operate on.
messageMessage to send.
sizeMessage size in bytes.
Returns
0 if all bytes were successfully written, negative value otherwise. Driver errno MUST be set to a non-zero value if the function fails.

◆ anjay_nidd_driver_system_descriptor_t

typedef int anjay_nidd_driver_system_descriptor_t(anjay_nidd_driver_t *driver, const void **out)

Returns a pointer to bare system handle to the device communication channel if possible (e.g. to invoke select or poll). The returned handle shall be interpreted in the same way as the value returned from avs_net_socket_get_system().

Parameters
driverDevice driver context to operate on.
outPointer to a variable in which to save the pointer to the system handle. May be NULL if the driver cannot provide any handle.
Returns
0 on success, or a negative value in case of error. Driver errno MUST be set to a non-zero value if the function fails.

Function Documentation

◆ anjay_nidd_driver_cleanup()

void anjay_nidd_driver_cleanup ( anjay_nidd_driver_t **  driver)

Cleanups driver context by freeing all resources associated with it, using user provided implementation of anjay_nidd_driver_free_t .

Sets *driver to NULL afterwards.

Parameters
driverPointer to a driver context to operate on.