SolarCapture C Bindings User Guide  SF-115721-CD
Draft 2A
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ext_packet.h File Reference

sc_packet: The representation of a packet or other data. More...

#include <stdlib.h>
#include <stdint.h>
#include <sys/uio.h>

Data Structures

struct  sc_packet
 Representation of a packet. More...
 

Macros

#define SC_MEMBER_OFFSET(c_type, mbr_name)   ((uint32_t) (uintptr_t)(&((c_type*)0)->mbr_name))
 Calculate memory offset of a field within a struct. More...
 
#define SC_MEMBER_SIZE(c_type, mbr_name)   (sizeof(((c_type*)0)->mbr_name))
 Calculate the size of a field within a struct. More...
 
#define SC_FRAME_LEN_LARGE   UINT16_MAX
 struct sc_packet.frame_len holds this special value to indicate that the frame is "large". (Meaning it would overflow sc_packet.frame_len).
 
#define SC_CSUM_ERROR   (1 << 0)
 struct sc_packet.flags will have this set if the packet has a checksum error
 
#define SC_CRC_ERROR   (1 << 1)
 struct sc_packet.flags will have this set if the packet has a crc error
 
#define SC_TRUNCATED   (1 << 2)
 struct sc_packet.flags will have this set if the packet has been truncated
 
#define SC_MCAST_MISMATCH   (1 << 3)
 struct sc_packet.flags will have this set if the packet is for a multicast group the host hasn't joined
 
#define SC_UCAST_MISMATCH   (1 << 4)
 struct sc_packet.flags will have this set if the packet is for a unicast address not matching the host's
 

Functions

static int sc_packet_bytes (struct sc_packet *p)
 Return the size of the packet data in bytes. More...
 
static struct sc_packetsc_packet_frags_tail (struct sc_packet *p)
 Return a packet's last fragment. More...
 
static void sc_packet_prefetch_r (struct sc_packet *p)
 Prefetch a packet for reading. More...
 
static void sc_packet_prefetch_rw (struct sc_packet *p)
 Prefetch a packet for reading and writing. More...
 
static struct timespec sc_packet_timespec (const struct sc_packet *p)
 Return the timestamp of the packet in timespec format. More...
 

Detailed Description

sc_packet: The representation of a packet or other data.

Macro Definition Documentation

#define SC_MEMBER_OFFSET (   c_type,
  mbr_name 
)    ((uint32_t) (uintptr_t)(&((c_type*)0)->mbr_name))

Calculate memory offset of a field within a struct.

Parameters
c_typeThe struct type.
mbr_nameThe field name to calculate the offset of.
#define SC_MEMBER_SIZE (   c_type,
  mbr_name 
)    (sizeof(((c_type*)0)->mbr_name))

Calculate the size of a field within a struct.

Parameters
c_typeThe struct type.
mbr_nameThe field to calculate the size of.

Function Documentation

static int sc_packet_bytes ( struct sc_packet p)
inlinestatic

Return the size of the packet data in bytes.

Parameters
pA packet object.
Returns
The size of the packet data in bytes.
static struct sc_packet* sc_packet_frags_tail ( struct sc_packet p)
static

Return a packet's last fragment.

Parameters
pA packet object.
Returns
The packet's last fragment.

The result is only valid if the packet has at least one fragment.

static void sc_packet_prefetch_r ( struct sc_packet p)
inlinestatic

Prefetch a packet for reading.

Parameters
pA packet object.
static void sc_packet_prefetch_rw ( struct sc_packet p)
inlinestatic

Prefetch a packet for reading and writing.

Parameters
pA packet object.
static struct timespec sc_packet_timespec ( const struct sc_packet p)
static

Return the timestamp of the packet in timespec format.

Parameters
pA packet object.
Returns
The timestamp of the packet in timespec format.