libSNAP v1.0.0
Open source C/C++ library for the Scaleable Node Address Protocol (SNAP)
User Convenience

Function-like macros defined just for user convenience. Most of them are wrappers for functions and other macros. More...

Collaboration diagram for User Convenience:

Get frame content

#define snap_getSync()   (SNAP_SYNC)
 Get the value of the sync byte.
 
#define snap_getHdb2(pFrame)   (SNAP_HDB2((pFrame)->buffer))
 Get the HDB2 byte of a frame. More...
 
#define snap_getHdb1(pFrame)   (SNAP_HDB1((pFrame)->buffer))
 Get the HDB1 byte of a frame. More...
 
#define snap_getDab(pFrame)   (SNAP_HDB2_DAB((pFrame)->buffer))
 Get the DAB bits of a frame. More...
 
#define snap_getSab(pFrame)   (SNAP_HDB2_SAB((pFrame)->buffer))
 Get the SAB bits of a frame. More...
 
#define snap_getPfb(pFrame)   (SNAP_HDB2_PFB((pFrame)->buffer))
 Get the PFB bits of a frame. More...
 
#define snap_getAck(pFrame)   (SNAP_HDB2_ACK((pFrame)->buffer))
 Get the ACK bits of a frame. More...
 
#define snap_getCmd(pFrame)   (SNAP_HDB1_CMD((pFrame)->buffer))
 Get the CMD bit of a frame. More...
 
#define snap_getEdm(pFrame)   (SNAP_HDB1_EDM((pFrame)->buffer))
 Get the EDM bits of a frame. More...
 
#define snap_getNdb(pFrame)   (SNAP_HDB1_NDB((pFrame)->buffer))
 Get the NDB bits of a frame. More...
 
#define snap_getHeader(pFrame, pHeader)   (snap_getField(pFrame, pHeader, SNAP_FIELD_HEADER))
 Get the header of a frame. More...
 
#define snap_getDestAddress(pFrame, pDestAddr)   (snap_getField(pFrame, pDestAddr, SNAP_FIELD_DEST_ADDRESS))
 Get the destination address of a frame. More...
 
#define snap_getSourceAddress(pFrame, pSourceAddr)   (snap_getField(pFrame, pSourceAddr, SNAP_FIELD_SOURCE_ADDRESS))
 Get the source address of a frame. More...
 
#define snap_getProtocolFlags(pFrame, pFlags)   (snap_getField(pFrame, pFlags, SNAP_FIELD_PROTOCOL_FLAGS))
 Get the protocol flags of a frame. More...
 
#define snap_getData(pFrame, pData)   (snap_getField(pFrame, pData, SNAP_FIELD_DATA))
 Get the data bytes of a frame. More...
 
#define snap_getHash(pFrame, pHash)   (snap_getField(pFrame, pHash, SNAP_FIELD_HASH))
 Get the hash value of a frame. More...
 
#define snap_getDataPtr(pFrame)   ((pFrame)->buffer + SNAP_INDEX_DATA((pFrame)->buffer))
 Get the pointer to the first data byte of a frame. More...
 
#define snap_getBufferPtr(pFrame)   ((pFrame)->buffer)
 Get the pointer to the first byte of a frame. More...
 
#define snap_getStatus(pFrame)   ((pFrame)->status)
 Get the frame status (it can be any value from snap_status_t). More...
 

Get field indexes

#define snap_getSyncIndex()   (SNAP_INDEX_SYNC)
 Get the index of the sync byte.
 
#define snap_getHdb2Index()   (SNAP_INDEX_HDB2)
 Get the index of the HDB2 byte.
 
#define snap_getHdb1Index()   (SNAP_INDEX_HDB1)
 Get the index of the HDB1 byte.
 
#define snap_getHeaderIndex()   (SNAP_INDEX_HDB2)
 Get the index of the first header byte (HDB2).
 
#define snap_getDestAddrIndex()   (SNAP_INDEX_DAB)
 Get the index of the first (MSB) destination address byte (if there are any).
 
#define snap_getSourceAddrIndex(pFrame)   (SNAP_INDEX_SAB((pFrame)->buffer))
 Get the index of the first (MSB) source address byte (if there are any). More...
 
#define snap_getProtFlagsIndex(pFrame)   (SNAP_INDEX_PFB((pFrame)->buffer))
 Get the index of the first (MSB) protocol flags byte (if there are any). More...
 
#define snap_getDataIndex(pFrame)   (SNAP_INDEX_DATA((pFrame)->buffer))
 Get the index of the first data byte (if there are any). More...
 
#define snap_getHashIndex(pFrame)   (SNAP_INDEX_HASH((pFrame)->buffer))
 Get the index of the first (MSB) data byte (if there are any). More...
 

Get frame and field sizes

#define snap_getSyncSize()   (SNAP_SIZE_SYNC)
 Get the size of the sync field.
 
#define snap_getHdb2Size()   (SNAP_SIZE_HDB2)
 Get the size of the HDB2 field.
 
#define snap_getHdb1Size()   (SNAP_SIZE_HDB1)
 Get the size of the HDB1 field.
 
#define snap_getHeaderSize()   (SNAP_SIZE_HEADER)
 Get the size of the header field.
 
#define snap_getDestAddrSize(pFrame)   (SNAP_HDB2_DAB((pFrame)->buffer))
 Get the size of the destination address. More...
 
#define snap_getSourceAddrSize(pFrame)   (SNAP_HDB2_SAB((pFrame)->buffer))
 Get the size of the source address. More...
 
#define snap_getProtFlagsSize(pFrame)   (SNAP_HDB2_PFB((pFrame)->buffer))
 Get the size of the protocol flags. More...
 
#define snap_getDataSize(pFrame)   (SNAP_SIZE_DATA((pFrame)->buffer))
 Get the size of the data field. More...
 
#define snap_getHashSize(pFrame)   (SNAP_SIZE_HASH((pFrame)->buffer))
 Get the size of the hash field. More...
 
#define snap_getFrameSize(pFrame)   ((pFrame)->size)
 Get the current size of a frame (it may be incomplete). More...
 
#define snap_getBufferSize(pFrame)   ((pFrame)->maxSize)
 Get the maximum number of bytes that can be stored in the buffer. More...
 
#define snap_getFullFrameSize(pFrame)   (SNAP_INDEX_HASH((pFrame)->buffer) + SNAP_SIZE_HASH((pFrame)->buffer))
 Get the size of a frame as if it were complete (based on the header). More...
 

Detailed Description

Function-like macros defined just for user convenience. Most of them are wrappers for functions and other macros.

Note
Only functions actually check the frame for errors (e.g. incomplete frame, wrong frame format, etc). Before using macros that are not wrappers of the function snap_getField(), be sure the operation is valid (i.e. the frame has a valid header, the frame format has the requested field, etc).

Macro Definition Documentation

◆ snap_getHdb2

#define snap_getHdb2 (   pFrame)    (SNAP_HDB2((pFrame)->buffer))

Get the HDB2 byte of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getHdb1

#define snap_getHdb1 (   pFrame)    (SNAP_HDB1((pFrame)->buffer))

Get the HDB1 byte of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getDab

#define snap_getDab (   pFrame)    (SNAP_HDB2_DAB((pFrame)->buffer))

Get the DAB bits of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getSab

#define snap_getSab (   pFrame)    (SNAP_HDB2_SAB((pFrame)->buffer))

Get the SAB bits of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getPfb

#define snap_getPfb (   pFrame)    (SNAP_HDB2_PFB((pFrame)->buffer))

Get the PFB bits of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getAck

#define snap_getAck (   pFrame)    (SNAP_HDB2_ACK((pFrame)->buffer))

Get the ACK bits of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getCmd

#define snap_getCmd (   pFrame)    (SNAP_HDB1_CMD((pFrame)->buffer))

Get the CMD bit of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getEdm

#define snap_getEdm (   pFrame)    (SNAP_HDB1_EDM((pFrame)->buffer))

Get the EDM bits of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getNdb

#define snap_getNdb (   pFrame)    (SNAP_HDB1_NDB((pFrame)->buffer))

Get the NDB bits of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getHeader

#define snap_getHeader (   pFrame,
  pHeader 
)    (snap_getField(pFrame, pHeader, SNAP_FIELD_HEADER))

Get the header of a frame.

Parameters
pFramePointer to the frame structure (*snap_frame_t*).
pHeaderPointer to the variable that will store the header (snap_header_t*).

◆ snap_getDestAddress

#define snap_getDestAddress (   pFrame,
  pDestAddr 
)    (snap_getField(pFrame, pDestAddr, SNAP_FIELD_DEST_ADDRESS))

Get the destination address of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).
pDestAddrPointer to the variable that will store the address (uint32_t*).

◆ snap_getSourceAddress

#define snap_getSourceAddress (   pFrame,
  pSourceAddr 
)    (snap_getField(pFrame, pSourceAddr, SNAP_FIELD_SOURCE_ADDRESS))

Get the source address of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).
pSourceAddrPointer to the variable that will store the address (uint32_t*).

◆ snap_getProtocolFlags

#define snap_getProtocolFlags (   pFrame,
  pFlags 
)    (snap_getField(pFrame, pFlags, SNAP_FIELD_PROTOCOL_FLAGS))

Get the protocol flags of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).
pFlagsPointer to the variable that will store the flags (uint32_t*).

◆ snap_getData

#define snap_getData (   pFrame,
  pData 
)    (snap_getField(pFrame, pData, SNAP_FIELD_DATA))

Get the data bytes of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).
pDataPointer to the byte array that will store the data (uint8_t*).

◆ snap_getHash

#define snap_getHash (   pFrame,
  pHash 
)    (snap_getField(pFrame, pHash, SNAP_FIELD_HASH))

Get the hash value of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).
pHashPointer to the variable that will store the hash value (uint32_t*).

◆ snap_getDataPtr

#define snap_getDataPtr (   pFrame)    ((pFrame)->buffer + SNAP_INDEX_DATA((pFrame)->buffer))

Get the pointer to the first data byte of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getBufferPtr

#define snap_getBufferPtr (   pFrame)    ((pFrame)->buffer)

Get the pointer to the first byte of a frame.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getStatus

#define snap_getStatus (   pFrame)    ((pFrame)->status)

Get the frame status (it can be any value from snap_status_t).

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getSourceAddrIndex

#define snap_getSourceAddrIndex (   pFrame)    (SNAP_INDEX_SAB((pFrame)->buffer))

Get the index of the first (MSB) source address byte (if there are any).

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getProtFlagsIndex

#define snap_getProtFlagsIndex (   pFrame)    (SNAP_INDEX_PFB((pFrame)->buffer))

Get the index of the first (MSB) protocol flags byte (if there are any).

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getDataIndex

#define snap_getDataIndex (   pFrame)    (SNAP_INDEX_DATA((pFrame)->buffer))

Get the index of the first data byte (if there are any).

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getHashIndex

#define snap_getHashIndex (   pFrame)    (SNAP_INDEX_HASH((pFrame)->buffer))

Get the index of the first (MSB) data byte (if there are any).

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getDestAddrSize

#define snap_getDestAddrSize (   pFrame)    (SNAP_HDB2_DAB((pFrame)->buffer))

Get the size of the destination address.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getSourceAddrSize

#define snap_getSourceAddrSize (   pFrame)    (SNAP_HDB2_SAB((pFrame)->buffer))

Get the size of the source address.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getProtFlagsSize

#define snap_getProtFlagsSize (   pFrame)    (SNAP_HDB2_PFB((pFrame)->buffer))

Get the size of the protocol flags.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getDataSize

#define snap_getDataSize (   pFrame)    (SNAP_SIZE_DATA((pFrame)->buffer))

Get the size of the data field.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getHashSize

#define snap_getHashSize (   pFrame)    (SNAP_SIZE_HASH((pFrame)->buffer))

Get the size of the hash field.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getFrameSize

#define snap_getFrameSize (   pFrame)    ((pFrame)->size)

Get the current size of a frame (it may be incomplete).

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getBufferSize

#define snap_getBufferSize (   pFrame)    ((pFrame)->maxSize)

Get the maximum number of bytes that can be stored in the buffer.

Parameters
pFramePointer to the frame structure (snap_frame_t*).

◆ snap_getFullFrameSize

#define snap_getFullFrameSize (   pFrame)    (SNAP_INDEX_HASH((pFrame)->buffer) + SNAP_SIZE_HASH((pFrame)->buffer))

Get the size of a frame as if it were complete (based on the header).

Parameters
pFramePointer to the frame structure (snap_frame_t*).