Data Structures

union  csp_id_t
 This union defines a CSP identifier and allows access to the individual fields or the entire identifier. More...
 
struct  csp_packet_t
 CSP PACKET STRUCTURE Note: This structure is constructed to fit with all interface frame types in order to have buffer reuse. More...
 
struct  csp_iface_s
 Interface struct. More...
 

Macros

#define bool   int
 
#define false   0
 
#define true   !false
 
#define CSP_PRIORITIES   (1 << CSP_ID_PRIO_SIZE)
 
#define CSP_RX_QUEUE_LENGTH   CSP_CONN_QUEUE_LENGTH
 
#define CSP_ROUTE_FIFOS   1
 
#define CSP_RX_QUEUES   1
 
#define CSP_ID_PRIO_SIZE   2
 Size of bit-fields in CSP header. More...
 
#define CSP_ID_HOST_SIZE   5
 
#define CSP_ID_PORT_SIZE   6
 
#define CSP_ID_FLAGS_SIZE   8
 
#define CSP_HEADER_BITS   (CSP_ID_PRIO_SIZE + 2 * CSP_ID_HOST_SIZE + 2 * CSP_ID_PORT_SIZE + CSP_ID_FLAGS_SIZE)
 
#define CSP_HEADER_LENGTH   (CSP_HEADER_BITS/8)
 
#define CSP_ID_PRIO_MAX   ((1 << (CSP_ID_PRIO_SIZE)) - 1)
 Highest number to be entered in field. More...
 
#define CSP_ID_HOST_MAX   ((1 << (CSP_ID_HOST_SIZE)) - 1)
 
#define CSP_ID_PORT_MAX   ((1 << (CSP_ID_PORT_SIZE)) - 1)
 
#define CSP_ID_FLAGS_MAX   ((1 << (CSP_ID_FLAGS_SIZE)) - 1)
 
#define CSP_ID_PRIO_MASK   ((uint32_t) CSP_ID_PRIO_MAX << (CSP_ID_FLAGS_SIZE + 2 * CSP_ID_PORT_SIZE + 2 * CSP_ID_HOST_SIZE))
 Identifier field masks. More...
 
#define CSP_ID_SRC_MASK   ((uint32_t) CSP_ID_HOST_MAX << (CSP_ID_FLAGS_SIZE + 2 * CSP_ID_PORT_SIZE + 1 * CSP_ID_HOST_SIZE))
 
#define CSP_ID_DST_MASK   ((uint32_t) CSP_ID_HOST_MAX << (CSP_ID_FLAGS_SIZE + 2 * CSP_ID_PORT_SIZE))
 
#define CSP_ID_DPORT_MASK   ((uint32_t) CSP_ID_PORT_MAX << (CSP_ID_FLAGS_SIZE + 1 * CSP_ID_PORT_SIZE))
 
#define CSP_ID_SPORT_MASK   ((uint32_t) CSP_ID_PORT_MAX << (CSP_ID_FLAGS_SIZE))
 
#define CSP_ID_FLAGS_MASK   ((uint32_t) CSP_ID_FLAGS_MAX << (0))
 
#define CSP_ID_CONN_MASK   (CSP_ID_SRC_MASK | CSP_ID_DST_MASK | CSP_ID_DPORT_MASK | CSP_ID_SPORT_MASK)
 
#define CSP_BROADCAST_ADDR   CSP_ID_HOST_MAX
 Broadcast address. More...
 
#define CSP_DEFAULT_ROUTE   (CSP_ID_HOST_MAX + 1)
 Default routing address. More...
 
#define CSP_FRES1   0x80
 CSP Flags. More...
 
#define CSP_FRES2   0x40
 
#define CSP_FRES3   0x20
 
#define CSP_FFRAG   0x10
 
#define CSP_FHMAC   0x08
 
#define CSP_FXTEA   0x04
 
#define CSP_FRDP   0x02
 
#define CSP_FCRC32   0x01
 
#define CSP_SO_NONE   0x0000
 CSP Socket options. More...
 
#define CSP_SO_RDPREQ   0x0001
 
#define CSP_SO_RDPPROHIB   0x0002
 
#define CSP_SO_HMACREQ   0x0004
 
#define CSP_SO_HMACPROHIB   0x0008
 
#define CSP_SO_XTEAREQ   0x0010
 
#define CSP_SO_XTEAPROHIB   0x0020
 
#define CSP_SO_CRC32REQ   0x0040
 
#define CSP_SO_CRC32PROHIB   0x0080
 
#define CSP_SO_CONN_LESS   0x0100
 
#define CSP_O_NONE   CSP_SO_NONE
 CSP Connect options. More...
 
#define CSP_O_RDP   CSP_SO_RDPREQ
 
#define CSP_O_NORDP   CSP_SO_RDPPROHIB
 
#define CSP_O_HMAC   CSP_SO_HMACREQ
 
#define CSP_O_NOHMAC   CSP_SO_HMACPROHIB
 
#define CSP_O_XTEA   CSP_SO_XTEAREQ
 
#define CSP_O_NOXTEA   CSP_SO_XTEAPROHIB
 
#define CSP_O_CRC32   CSP_SO_CRC32REQ
 
#define CSP_O_NOCRC32   CSP_SO_CRC32PROHIB
 
#define CSP_BUFFER_PACKET_OVERHEAD   (sizeof(csp_packet_t) - sizeof(((csp_packet_t *)0)->data))
 This define must be equal to the size of the packet overhead in csp_packet_t. More...
 
#define CSP_HOSTNAME_LEN   20
 
#define CSP_MODEL_LEN   30
 
#define CSP_REBOOT_MAGIC   0x80078007
 
#define CSP_REBOOT_SHUTDOWN_MAGIC   0xD1E5529A
 

Typedefs

typedef int(* nexthop_t) (struct csp_iface_s *interface, csp_packet_t *packet, uint32_t timeout)
 
typedef struct csp_iface_s csp_iface_t
 Interface struct. More...
 
typedef struct csp_conn_s csp_socket_t
 Forward declaration of socket and connection structures. More...
 
typedef struct csp_conn_s csp_conn_t
 

Enumerations

enum  csp_reserved_ports_e {
  CSP_CMP = 0, CSP_PING = 1, CSP_PS = 2, CSP_MEMFREE = 3,
  CSP_REBOOT = 4, CSP_BUF_FREE = 5, CSP_UPTIME = 6, CSP_ANY = (CSP_MAX_BIND_PORT + 1),
  CSP_PROMISC = (CSP_MAX_BIND_PORT + 2)
}
 RESERVED PORTS (SERVICES) More...
 
enum  csp_prio_t { CSP_PRIO_CRITICAL = 0, CSP_PRIO_HIGH = 1, CSP_PRIO_NORM = 2, CSP_PRIO_LOW = 3 }
 

Data Structure Documentation

union csp_id_t

This union defines a CSP identifier and allows access to the individual fields or the entire identifier.

Data Fields

uint32_t ext
 
struct {
}; 
 

Field Documentation

struct { ... }
uint32_t csp_id_t::ext
struct csp_packet_t

CSP PACKET STRUCTURE Note: This structure is constructed to fit with all interface frame types in order to have buffer reuse.

Data Fields

uint8_t padding [CSP_PADDING_BYTES]
 Interface dependent padding. More...
 
uint16_t length
 Length field must be just before CSP ID. More...
 
csp_id_t id
 CSP id must be just before data. More...
 
union {
   uint8_t   data [0]
 This just points to the rest of the buffer, without a size indication. More...
 
   uint16_t   data16 [0]
 The data 16 and 32 types makes it easy to reference an integer (properly aligned) More...
 
   uint32_t   data32 [0]
 without the compiler warning about strict aliasing rules. More...
 
}; 
 

Field Documentation

union { ... }
uint8_t csp_packet_t::data[0]

This just points to the rest of the buffer, without a size indication.

uint16_t csp_packet_t::data16[0]

The data 16 and 32 types makes it easy to reference an integer (properly aligned)

uint32_t csp_packet_t::data32[0]

without the compiler warning about strict aliasing rules.

csp_id_t csp_packet_t::id

CSP id must be just before data.

uint16_t csp_packet_t::length

Length field must be just before CSP ID.

uint8_t csp_packet_t::padding[CSP_PADDING_BYTES]

Interface dependent padding.

struct csp_iface_s

Interface struct.

Data Fields

const char * name
 Interface name (keep below 10 bytes) More...
 
void * driver
 Pointer to interface handler structure. More...
 
nexthop_t nexthop
 Next hop function. More...
 
uint16_t mtu
 Maximum Transmission Unit of interface. More...
 
uint8_t split_horizon_off
 Disable the route-loop prevention on if. More...
 
uint32_t tx
 Successfully transmitted packets. More...
 
uint32_t rx
 Successfully received packets. More...
 
uint32_t tx_error
 Transmit errors. More...
 
uint32_t rx_error
 Receive errors. More...
 
uint32_t drop
 Dropped packets. More...
 
uint32_t autherr
 Authentication errors. More...
 
uint32_t frame
 Frame format errors. More...
 
uint32_t txbytes
 Transmitted bytes. More...
 
uint32_t rxbytes
 Received bytes. More...
 
uint32_t irq
 Interrupts. More...
 
struct csp_iface_snext
 Next interface. More...
 

Field Documentation

uint32_t csp_iface_s::autherr

Authentication errors.

void* csp_iface_s::driver

Pointer to interface handler structure.

uint32_t csp_iface_s::drop

Dropped packets.

uint32_t csp_iface_s::frame

Frame format errors.

uint32_t csp_iface_s::irq

Interrupts.

uint16_t csp_iface_s::mtu

Maximum Transmission Unit of interface.

const char* csp_iface_s::name

Interface name (keep below 10 bytes)

struct csp_iface_s* csp_iface_s::next

Next interface.

nexthop_t csp_iface_s::nexthop

Next hop function.

uint32_t csp_iface_s::rx

Successfully received packets.

uint32_t csp_iface_s::rx_error

Receive errors.

uint32_t csp_iface_s::rxbytes

Received bytes.

uint8_t csp_iface_s::split_horizon_off

Disable the route-loop prevention on if.

uint32_t csp_iface_s::tx

Successfully transmitted packets.

uint32_t csp_iface_s::tx_error

Transmit errors.

uint32_t csp_iface_s::txbytes

Transmitted bytes.

Macro Definition Documentation

#define bool   int
#define CSP_BROADCAST_ADDR   CSP_ID_HOST_MAX

Broadcast address.

#define CSP_BUFFER_PACKET_OVERHEAD   (sizeof(csp_packet_t) - sizeof(((csp_packet_t *)0)->data))

This define must be equal to the size of the packet overhead in csp_packet_t.

It is used in csp_buffer_get() to check the allocated buffer size against the required buffer size.

#define CSP_DEFAULT_ROUTE   (CSP_ID_HOST_MAX + 1)

Default routing address.

#define CSP_FCRC32   0x01
#define CSP_FFRAG   0x10
#define CSP_FHMAC   0x08
#define CSP_FRDP   0x02
#define CSP_FRES1   0x80

CSP Flags.

#define CSP_FRES2   0x40
#define CSP_FRES3   0x20
#define CSP_FXTEA   0x04
#define CSP_HEADER_BITS   (CSP_ID_PRIO_SIZE + 2 * CSP_ID_HOST_SIZE + 2 * CSP_ID_PORT_SIZE + CSP_ID_FLAGS_SIZE)
#define CSP_HEADER_LENGTH   (CSP_HEADER_BITS/8)
#define CSP_HOSTNAME_LEN   20
#define CSP_ID_CONN_MASK   (CSP_ID_SRC_MASK | CSP_ID_DST_MASK | CSP_ID_DPORT_MASK | CSP_ID_SPORT_MASK)
#define CSP_ID_DPORT_MASK   ((uint32_t) CSP_ID_PORT_MAX << (CSP_ID_FLAGS_SIZE + 1 * CSP_ID_PORT_SIZE))
#define CSP_ID_DST_MASK   ((uint32_t) CSP_ID_HOST_MAX << (CSP_ID_FLAGS_SIZE + 2 * CSP_ID_PORT_SIZE))
#define CSP_ID_FLAGS_MASK   ((uint32_t) CSP_ID_FLAGS_MAX << (0))
#define CSP_ID_FLAGS_MAX   ((1 << (CSP_ID_FLAGS_SIZE)) - 1)
#define CSP_ID_FLAGS_SIZE   8
#define CSP_ID_HOST_MAX   ((1 << (CSP_ID_HOST_SIZE)) - 1)
#define CSP_ID_HOST_SIZE   5
#define CSP_ID_PORT_MAX   ((1 << (CSP_ID_PORT_SIZE)) - 1)
#define CSP_ID_PORT_SIZE   6
#define CSP_ID_PRIO_MASK   ((uint32_t) CSP_ID_PRIO_MAX << (CSP_ID_FLAGS_SIZE + 2 * CSP_ID_PORT_SIZE + 2 * CSP_ID_HOST_SIZE))

Identifier field masks.

#define CSP_ID_PRIO_MAX   ((1 << (CSP_ID_PRIO_SIZE)) - 1)

Highest number to be entered in field.

#define CSP_ID_PRIO_SIZE   2

Size of bit-fields in CSP header.

#define CSP_ID_SPORT_MASK   ((uint32_t) CSP_ID_PORT_MAX << (CSP_ID_FLAGS_SIZE))
#define CSP_ID_SRC_MASK   ((uint32_t) CSP_ID_HOST_MAX << (CSP_ID_FLAGS_SIZE + 2 * CSP_ID_PORT_SIZE + 1 * CSP_ID_HOST_SIZE))
#define CSP_MODEL_LEN   30
#define CSP_O_CRC32   CSP_SO_CRC32REQ
#define CSP_O_HMAC   CSP_SO_HMACREQ
#define CSP_O_NOCRC32   CSP_SO_CRC32PROHIB
#define CSP_O_NOHMAC   CSP_SO_HMACPROHIB
#define CSP_O_NONE   CSP_SO_NONE

CSP Connect options.

#define CSP_O_NORDP   CSP_SO_RDPPROHIB
#define CSP_O_NOXTEA   CSP_SO_XTEAPROHIB
#define CSP_O_RDP   CSP_SO_RDPREQ
#define CSP_O_XTEA   CSP_SO_XTEAREQ
#define CSP_PRIORITIES   (1 << CSP_ID_PRIO_SIZE)
#define CSP_REBOOT_MAGIC   0x80078007
#define CSP_REBOOT_SHUTDOWN_MAGIC   0xD1E5529A
#define CSP_ROUTE_FIFOS   1
#define CSP_RX_QUEUE_LENGTH   CSP_CONN_QUEUE_LENGTH
#define CSP_RX_QUEUES   1
#define CSP_SO_CONN_LESS   0x0100
#define CSP_SO_CRC32PROHIB   0x0080
#define CSP_SO_CRC32REQ   0x0040
#define CSP_SO_HMACPROHIB   0x0008
#define CSP_SO_HMACREQ   0x0004
#define CSP_SO_NONE   0x0000

CSP Socket options.

#define CSP_SO_RDPPROHIB   0x0002
#define CSP_SO_RDPREQ   0x0001
#define CSP_SO_XTEAPROHIB   0x0020
#define CSP_SO_XTEAREQ   0x0010
#define false   0
#define true   !false

Typedef Documentation

typedef struct csp_conn_s csp_conn_t
typedef struct csp_iface_s csp_iface_t

Interface struct.

typedef struct csp_conn_s csp_socket_t

Forward declaration of socket and connection structures.

typedef int(* nexthop_t) (struct csp_iface_s *interface, csp_packet_t *packet, uint32_t timeout)

Enumeration Type Documentation

enum csp_prio_t
Enumerator
CSP_PRIO_CRITICAL 
CSP_PRIO_HIGH 
CSP_PRIO_NORM 
CSP_PRIO_LOW 

RESERVED PORTS (SERVICES)

Enumerator
CSP_CMP 
CSP_PING 
CSP_PS 
CSP_MEMFREE 
CSP_REBOOT 
CSP_BUF_FREE 
CSP_UPTIME 
CSP_ANY 
CSP_PROMISC