Source code for csp_interface.h

/****************************************************************************
 * **File:** csp/csp_interface.h
 *
 * **Description:** CSP Interface
 ****************************************************************************/
#pragma once

#include <csp/csp_types.h>

#ifdef __cplusplus
extern "C" {
#endif

#define CSP_IFLIST_NAME_MAX 10
[docs]/** * Interface Tx function. * * @return #CSP_ERR_NONE on success, otherwise an error code. */ typedef int (*nexthop_t)(csp_iface_t * iface, uint16_t via, csp_packet_t * packet, int from_me);
[docs]/** * This struct is referenced in documentation. * Update doc when you change this. */ struct csp_iface_s { /* Interface settings */
[docs] uint16_t addr; /**< Host address on this subnet */
[docs] uint16_t netmask; /**< Subnet mask */
[docs] const char * name; /**< Name, max compare length is #CSP_IFLIST_NAME_MAX */
[docs] void * interface_data; /**< Interface data, only known/used by the interface layer, e.g. state information. */
[docs] void * driver_data; /**< Driver data, only known/used by the driver layer, e.g. device/channel references. */
[docs] nexthop_t nexthop; /**< Next hop (Tx) function */
[docs] uint8_t is_default; /**< Set default IF flag (CSP supports multiple defaults) */
/* Stats */
[docs] uint32_t tx; /**< Successfully transmitted packets */
[docs] uint32_t rx; /**< Successfully received packets */
[docs] uint32_t tx_error; /**< Transmit errors (packets) */
[docs] uint32_t rx_error; /**< Receive errors, e.g. too large message */
[docs] uint32_t drop; /**< Dropped packets */
[docs] uint32_t autherr; /**< Authentication errors (packets) */
[docs] uint32_t frame; /**< Frame format errors (packets) */
[docs] uint32_t txbytes; /**< Transmitted bytes */
[docs] uint32_t rxbytes; /**< Received bytes */
[docs] uint32_t irq; /**< Interrupts */
/* For linked lists*/
[docs] struct csp_iface_s * next;
};
[docs]/** * Inputs a new packet into the system. * * This function can be called from interface drivers (ISR) or tasks, to route and accept packets. * * .. note:: EXTREMELY IMPORTANT: \a pxTaskWoken must ALWAYS be NULL if called from task, and ALWAYS * be NON NULL if called from ISR. If this condition is met, this call is completely thread-safe * * This function is fire and forget, it returns void, meaning that the \a packet will always be * either accepted or dropped, so the memory will always be freed. * * @param[in] packet A pointer to the incoming packet * @param[in] iface A pointer to the incoming interface TX function. * @param[in] pxTaskWoken Valid reference if called from ISR, otherwise NULL! * */ void csp_qfifo_write(csp_packet_t * packet, csp_iface_t * iface, void * pxTaskWoken);
#ifdef __cplusplus } #endif