netmsgs  1.2.2
RoadNarrows Robotics Network Messaging Package
nmLibPackFlat.c File Reference

Flat message packing/unpacking definitions. More...

#include <stdio.h>
#include <stdlib.h>
#include <libgen.h>
#include <string.h>
#include "rnr/rnrconfig.h"
#include "rnr/log.h"
#include "rnr/netmsgs.h"
#include "nmLibInternal.h"

Go to the source code of this file.

Functions

static NMPackFunc_T nmLookupFlatPacker (NMFType_T eFType)
 Lookup Flat packer function, given the message field type. More...
 
static NMUnpackFunc_T nmLookupFlatUnpacker (NMFType_T eFType)
 Lookup Flat unpacker function, given the message field type. More...
 
static int nmPackFlatStream (const NMMsgDef_T *pMsgDef, void *pStruct, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a Flat message. More...
 
static int nmUnpackFlatStream (const NMMsgDef_T *pMsgDef, byte_t buf[], size_t uMsgLen, void *pStruct, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack an Flat byte stream. More...
 
static int nmPackFlatPad (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack pad bytes into the message buffer. More...
 
static int nmPackFlatBool (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a boolean into an 8-bit Flat field into the message buffer. More...
 
static int nmPackFlatU8 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack an unsigned 8-bit Flat field into the message buffer. More...
 
static int nmPackFlatS8 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a signed 8-bit Flat field into the message buffer. More...
 
static int nmPackFlatU16 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack an unsigned 16-bit Flat field into the message buffer. More...
 
static int nmPackFlatS16 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a signed 16-bit Flat field into the message buffer. More...
 
static int nmPackFlatU32 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack an unsigned 32-bit Flat field into the message buffer. More...
 
static int nmPackFlatS32 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a signed 32-bit Flat field into the message buffer. More...
 
static int nmPackFlatU64 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack an unsigned 64-bit Flat field into the message buffer. More...
 
static int nmPackFlatS64 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a signed 64-bit Flat field into the message buffer. More...
 
static int nmPackFlatF32 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a 32-bit floating-point number Flat field into the message buffer. More...
 
static int nmPackFlatF64 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a 64-bit floating-point number Flat field into the message buffer. More...
 
static int nmPackFlatP32 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a 32-bit pointer Flat field into the message buffer. More...
 
static int nmPackFlatP64 (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a 64-bit pointer Flat field into the message buffer. More...
 
static int nmPackFlatString (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack null-terminated, fixed length string Flat field into the message buffer. More...
 
static int nmPackFlatStruct (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack a structure Flat field into the message buffer. More...
 
static int nmPackFlatVector (const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
 Pack variable length vector Flat field into the message buffer. More...
 
static int nmUnpackFlatPad (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack pad byte from the message buffer. More...
 
static int nmUnpackFlatBool (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack an unsigned 8-bit boolean Flat field from the message buffer. More...
 
static int nmUnpackFlatU8 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack an unsigned 8-bit Flat field from the message buffer. More...
 
static int nmUnpackFlatS8 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack a signed 8-bit Flat field from the message buffer. More...
 
static int nmUnpackFlatU16 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack an unsigned 16-bit Flat field from the message buffer. More...
 
static int nmUnpackFlatS16 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack a signed 16-bit Flat field from the message buffer. More...
 
static int nmUnpackFlatU32 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack an unsigned 32-bit Flat field from the message buffer. More...
 
static int nmUnpackFlatS32 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack a signed 32-bit Flat field from the message buffer. More...
 
static int nmUnpackFlatU64 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack an unsigned 64-bit Flat field from the message buffer. More...
 
static int nmUnpackFlatS64 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack a signed 64-bit Flat field from the message buffer. More...
 
static int nmUnpackFlatF32 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack a 32-bit floating-point number Flat field from the message buffer. More...
 
static int nmUnpackFlatF64 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack a 64-bit floating-point number Flat field from the message buffer. More...
 
static int nmUnpackFlatP32 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack a 32-bit pointer Flat field from the message buffer. More...
 
static int nmUnpackFlatP64 (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack a 64-bit pointer Flat field from the message buffer. More...
 
static int nmUnpackFlatString (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack variable length string Flat field from the message buffer. More...
 
static int nmUnpackFlatStruct (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack structure Flat field from the message buffer. More...
 
static int nmUnpackFlatVector (const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
 Unpack variable length vector Flat field from the message buffer. More...
 
int nmPackFlatMsg (const NMMsgDef_T *pMsgDef, void *pStruct, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
 Pack an Flat message. More...
 
int nmPackFlatMsgDebug (const NMMsgDef_T *pMsgDef, void *pStruct, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
 Pack an Flat message, tracing message packing to stderr. More...
 
int nmUnpackFlatMsg (const NMMsgDef_T *pMsgDef, byte_t buf[], size_t uMsgLen, void *pStruct, NMEndian_T eEndian)
 Unpack a Flat message. More...
 
int nmUnpackFlatMsgDebug (const NMMsgDef_T *pMsgDef, byte_t buf[], size_t uMsgLen, void *pStruct, NMEndian_T eEndian)
 Unpack a Flat message, tracing unpacking to stderr. More...
 

Variables

static NMLookupTblEntry_T NMFlatLookupTbl []
 

Detailed Description

Flat message packing/unpacking definitions.

LastChangedDate
2010-02-16 08:12:53 -0700 (Tue, 16 Feb 2010)
Rev
248
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)

Definition in file nmLibPackFlat.c.

Function Documentation

static NMPackFunc_T nmLookupFlatPacker ( NMFType_T  eFType)
static

Lookup Flat packer function, given the message field type.

Parameters
eFTypeMessage field type.
Returns
Returns packer function on success, NULL on failure.

Definition at line 1337 of file nmLibPackFlat.c.

References NMLookupTblEntry_T::m_fnPack, NM_ECODE_INTERNAL, NMHashFType(), NMHashNoIdx, NMLIB_ASCII_FTYPE, and NMLIB_ERROR.

Referenced by nmPackFlatStream(), and nmPackFlatVector().

1338 {
1339  int idx;
1340 
1341  idx = NMHashFType(eFType);
1342 
1343  if( (idx != NMHashNoIdx) && (idx < arraysize(NMFlatLookupTbl)) )
1344  {
1345  if( NMFlatLookupTbl[idx].m_eFType == eFType )
1346  {
1347  return NMFlatLookupTbl[idx].m_fnPack;
1348  }
1349  else
1350  {
1352  "hashed eFtype='%c'(0x%02x) != tbl[%d].m_eFType='%c'(0x%02x)",
1353  NMLIB_ASCII_FTYPE(eFType), eFType,
1354  idx, NMLIB_ASCII_FTYPE(NMFlatLookupTbl[idx].m_eFType),
1355  NMFlatLookupTbl[idx].m_eFType);
1356  return NULL;
1357  }
1358  }
1359  else
1360  {
1361  return NULL;
1362  }
1363 }
static NMLookupTblEntry_T NMFlatLookupTbl[]
#define NMLIB_ERROR(ecode, fmt,...)
Log libnetmsgs error.
const int NMHashNoIdx
hash no index value
#define NM_ECODE_INTERNAL
internal inconsistency or bug
Definition: netmsgs.h:80
INLINE_IN_H int NMHashFType(NMFType_T eFType)
Field Type to Index hash function.
#define NMLIB_ASCII_FTYPE(ftype)
Printable ASCII Field Type.
NMPackFunc_T m_fnPack
packer
static NMUnpackFunc_T nmLookupFlatUnpacker ( NMFType_T  eFType)
static

Lookup Flat unpacker function, given the message field type.

Parameters
eFTypeMessage field type.
Returns
Returns unpacker function on success, NULL on failure.

Definition at line 1372 of file nmLibPackFlat.c.

References NMLookupTblEntry_T::m_fnUnpack, NM_ECODE_INTERNAL, NMHashFType(), NMHashNoIdx, NMLIB_ASCII_FTYPE, and NMLIB_ERROR.

Referenced by nmUnpackFlatStream(), and nmUnpackFlatVector().

1373 {
1374  int idx;
1375 
1376  idx = NMHashFType(eFType);
1377 
1378  if( (idx != NMHashNoIdx) && (idx < arraysize(NMFlatLookupTbl)) )
1379  {
1380  if( NMFlatLookupTbl[idx].m_eFType == eFType )
1381  {
1382  return NMFlatLookupTbl[idx].m_fnUnpack;
1383  }
1384  else
1385  {
1387  "hashed eFtype='%c'(0x%02x) != tbl[%d].m_eFType='%c'(0x%02x)",
1388  NMLIB_ASCII_FTYPE(eFType), eFType,
1389  idx, NMLIB_ASCII_FTYPE(NMFlatLookupTbl[idx].m_eFType),
1390  NMFlatLookupTbl[idx].m_eFType);
1391  return NULL;
1392  }
1393  }
1394  else
1395  {
1396  return NULL;
1397  }
1398 }
static NMLookupTblEntry_T NMFlatLookupTbl[]
#define NMLIB_ERROR(ecode, fmt,...)
Log libnetmsgs error.
const int NMHashNoIdx
hash no index value
#define NM_ECODE_INTERNAL
internal inconsistency or bug
Definition: netmsgs.h:80
INLINE_IN_H int NMHashFType(NMFType_T eFType)
Field Type to Index hash function.
#define NMLIB_ASCII_FTYPE(ftype)
Printable ASCII Field Type.
NMUnpackFunc_T m_fnUnpack
unpacker
static int nmPackFlatBool ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a boolean into an 8-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 120 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmPackBool().

126 {
127  bool_t val; // constrained field value
128  int n; // byte count/error code
129 
130  val = *((bool_t *)pVal);
131 
132  // pack field value
133  n = nmPackBool(val, buf, bufSize, eEndian);
134 
135  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%s", (val? "true": "false"));
136 
137  return n;
138 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
INLINE_IN_H int nmPackBool(bool_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack a boolean value into the message buffer.
Definition: netmsgs.h:564
static int nmPackFlatF32 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a 32-bit floating-point number Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 387 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackF32(), and nmSetF32().

393 {
394  float val; // constrained field value
395  int n; // byte count/error code
396 
397  // set field value
398  if( (n = nmSetF32(pFieldDef, pVal, &val)) != NM_OK )
399  {
400  return n;
401  }
402 
403  // pack field value
404  n = nmPackF32(val, buf, bufSize, eEndian);
405 
406  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%f", val);
407 
408  return n;
409 }
int nmPackF32(float val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack a 32-bit float into the message buffer.
Definition: nmLibPack.c:957
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
int nmSetF32(const NMFieldDef_T *pFieldDef, void *pValIn, float *pValOut)
Helper function to set a 32-bit floating point number.
static int nmPackFlatF64 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a 64-bit floating-point number Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 418 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackF64(), and nmSetF64().

424 {
425  double val; // constrained field value
426  int n; // byte count/error code
427 
428  // set field value
429  if( (n = nmSetF64(pFieldDef, pVal, &val)) != NM_OK )
430  {
431  return n;
432  }
433 
434  // pack field value
435  n = nmPackF64(val, buf, bufSize, eEndian);
436 
437  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%e", val);
438 
439  return n;
440 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
int nmSetF64(const NMFieldDef_T *pFieldDef, void *pValIn, double *pValOut)
Helper function to set a 64-bit floating point number.
int nmPackF64(double val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack a 64-bit float into the message buffer.
Definition: nmLibPack.c:1013
int nmPackFlatMsg ( const NMMsgDef_T pMsgDef,
void *  pStruct,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian 
)

Pack an Flat message.

Parameters
pMsgDefPointer to message definition.
[in]pStructPointer to the associated, populated message structure.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1417 of file nmLibPackFlat.c.

References NMCtl_T::m_bNoHdr, NMCTL_INIT_DECL, and nmPackFlatStream().

Referenced by nmUnpackPointer().

1422 {
1423  NMCtl_T ctl = NMCTL_INIT_DECL;
1424  int n; // byte count/error code
1425 
1426  ctl.m_bNoHdr = true;
1427 
1428  // pack stream
1429  n = nmPackFlatStream(pMsgDef, pStruct, buf, bufSize, eEndian, &ctl);
1430 
1431  return n;
1432 }
byte_t m_bNoHdr
do [not] include field header in byte stream
static int nmPackFlatStream(const NMMsgDef_T *pMsgDef, void *pStruct, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a Flat message.
#define NMCTL_INIT_DECL
Default Internal control declartion list.
Internal Control Structure.
int nmPackFlatMsgDebug ( const NMMsgDef_T pMsgDef,
void *  pStruct,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian 
)

Pack an Flat message, tracing message packing to stderr.

Parameters
pMsgDefPointer to message definition.
[in]pStructPointer to the associated, populated message structure.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1446 of file nmLibPackFlat.c.

References NMCtl_T::m_bNoHdr, NMCtl_T::m_bTrace, _nm_msg_def_struct::m_eMsgId, _nm_msg_def_struct::m_sMsgName, _nm_msg_def_struct::m_uCount, NMCTL_INIT_DECL, nmPackFlatStream(), and nmPrintBuf().

Referenced by nmUnpackPointer().

1451 {
1452  NMCtl_T ctl = NMCTL_INIT_DECL;
1453  int n; // byte count/error code
1454 
1455  ctl.m_bNoHdr = true;
1456  ctl.m_bTrace = true;
1457 
1458  // trace
1459  fprintf(stderr, "\n--- Packing Flat Message %s(%u): field_count=%zu\n",
1460  pMsgDef->m_sMsgName, pMsgDef->m_eMsgId, pMsgDef->m_uCount);
1461 
1462  // pack stream
1463  n = nmPackFlatStream(pMsgDef, pStruct, buf, bufSize, eEndian, &ctl);
1464 
1465  // trace final buffer
1466  if( n > 0 )
1467  {
1468  fprintf(stderr, "Output Buffer (%zu bytes):\n", (size_t)n);
1469  nmPrintBuf(stderr, NULL, buf, (size_t)n, 16, 0);
1470  fprintf(stderr, "\n");
1471  }
1472 
1473  return n;
1474 }
byte_t m_bNoHdr
do [not] include field header in byte stream
static int nmPackFlatStream(const NMMsgDef_T *pMsgDef, void *pStruct, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a Flat message.
byte_t m_bTrace
do [not] trace packing/unpacking
uint_t m_eMsgId
message id (globally unique)
Definition: netmsgs.h:407
size_t m_uCount
number of message fields
Definition: netmsgs.h:408
#define NMCTL_INIT_DECL
Default Internal control declartion list.
const char * m_sMsgName
message/struct string name
Definition: netmsgs.h:406
void nmPrintBuf(FILE *fp, const char *sPreface, byte_t buf[], size_t uCount, size_t uNLFreq, uint_t uCol)
Pretty print buffer to opened file stream.
Definition: nmLibUtils.c:138
Internal Control Structure.
static int nmPackFlatP32 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a 32-bit pointer Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 448 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmPackP32().

454 {
455  int n; // byte count/error code
456 
457  // pack field value
458  n = nmPackP32(pVal, buf, bufSize, eEndian);
459 
460  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%p", *((ulong_t *)pVal));
461 
462  return n;
463 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
int nmPackP32(void *val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack a 32-bit pointer into the message buffer.
Definition: nmLibPack.c:1113
static int nmPackFlatP64 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a 64-bit pointer Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 471 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmPackP64().

477 {
478  int n; // byte count/error code
479 
480  // pack field value
481  n = nmPackP64(pVal, buf, bufSize, eEndian);
482 
483  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%p", *((ulong_t *)pVal));
484 
485  return n;
486 }
int nmPackP64(void *val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack a 64-bit pointer into the message buffer.
Definition: nmLibPack.c:1160
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
static int nmPackFlatPad ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack pad bytes into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 89 of file nmLibPackFlat.c.

References _nm_field_def_struct::m_eFId, NMFieldThis_T::m_pad, _nm_field_def_struct::m_this, NMFieldThisPad_T::m_uCount, NM_ECODE_NOMEM, NMFVAL_PAD, NMLIB_RAISE_FIELD_ERROR, and NMLIB_TRACE_FIELD.

95 {
96  size_t uCount = pFieldDef->m_this.m_pad.m_uCount;
97 
98  // pack pad bytes
99  if( uCount <= bufSize )
100  {
101  memset(buf, NMFVAL_PAD, uCount);
102  NMLIB_TRACE_FIELD(NULL, buf, uCount, pCtl, "pad(%u)", pFieldDef->m_eFId);
103  return (int)uCount;
104  }
105 
106  // no more space in buffer for pad bytes
107  else
108  {
110  "buf_size=%zu < pad_count=%zu", bufSize, uCount);
111  }
112 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NMFVAL_PAD
pad field value same as tr id
Definition: netmsgs.h:208
NMFieldThis_T m_this
specific field information
Definition: netmsgs.h:385
#define NM_ECODE_NOMEM
not enough buffer memory available
Definition: netmsgs.h:73
size_t m_uCount
number of pad bytes
Definition: netmsgs.h:265
#define NMLIB_RAISE_FIELD_ERROR(ecode, p, fmt,...)
Raise libnetmsgs field error (i.e. return from calling function).
NMFieldThisPad_T m_pad
pad field specific info
Definition: netmsgs.h:364
uint_t m_eFId
filed id (message/struct unique)
Definition: netmsgs.h:382
static int nmPackFlatS16 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a signed 16-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 236 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackS16(), and nmSetS16().

242 {
243  short val; // constrained field value
244  int n; // byte count/error code
245 
246  // set field value
247  if( (n = nmSetS16(pFieldDef, pVal, &val)) != NM_OK )
248  {
249  return n;
250  }
251 
252  // pack field value
253  n = nmPackS16(val, buf, bufSize, eEndian);
254 
255  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%hd", val);
256 
257  return n;
258 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
int nmSetS16(const NMFieldDef_T *pFieldDef, void *pValIn, short *pValOut)
Helper function to set a signed 16-bit integer.
INLINE_IN_H int nmPackS16(short val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack a signed 16-bit integer into the message buffer.
Definition: netmsgs.h:500
static int nmPackFlatS32 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a signed 32-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 296 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackS32(), and nmSetS32().

302 {
303  int val; // constrained field value
304  int n; // byte count/error code
305 
306  // set field value
307  if( (n = nmSetS32(pFieldDef, pVal, &val)) != NM_OK )
308  {
309  return n;
310  }
311 
312  // pack field value
313  n = nmPackS32(val, buf, bufSize, eEndian);
314 
315  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%d", val);
316 
317  return n;
318 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
INLINE_IN_H int nmPackS32(int val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack a signed 32-bit integer into the message buffer.
Definition: netmsgs.h:512
int nmSetS32(const NMFieldDef_T *pFieldDef, void *pValIn, int *pValOut)
Helper function to set a signed 32-bit integer.
static int nmPackFlatS64 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a signed 64-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 356 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackS64(), and nmSetS64().

362 {
363  long long val; // constrained field value
364  int n; // byte count/error code
365 
366  // set field value
367  if( (n = nmSetS64(pFieldDef, pVal, &val)) != NM_OK )
368  {
369  return n;
370  }
371 
372  // pack field value
373  n = nmPackS64(val, buf, bufSize, eEndian);
374 
375  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%lld", val);
376 
377  return n;
378 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
int nmPackS64(long long val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack an signed 64-bit integer into the message buffer.
Definition: nmLibPack.c:885
int nmSetS64(const NMFieldDef_T *pFieldDef, void *pValIn, long long *pValOut)
Helper function to set a signed 64-bit integer.
static int nmPackFlatS8 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a signed 8-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 176 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackS8(), and nmSetS8().

182 {
183  signed char val; // constrained field value
184  int n; // byte count/error code
185 
186  // try to set field value
187  if( (n = nmSetS8(pFieldDef, pVal, &val)) != NM_OK )
188  {
189  return n;
190  }
191 
192  // pack field value
193  n = nmPackS8(val, buf, bufSize, eEndian);
194 
195  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%hhd", val);
196 
197  return n;
198 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
int nmSetS8(const NMFieldDef_T *pFieldDef, void *pValIn, signed char *pValOut)
Helper function to set a signed 8-bit integer.
INLINE_IN_H int nmPackS8(signed char val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack a signed 8-bit byte into the message buffer.
Definition: netmsgs.h:488
static int nmPackFlatStream ( const NMMsgDef_T pMsgDef,
void *  pStruct,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a Flat message.

Parameters
pMsgDefPointer to message definition.
[in]pStructPointer to the associated, populated message structure.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlPointer to Internal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 690 of file nmLibPackFlat.c.

References _nm_field_def_struct::m_eFType, _nm_msg_def_struct::m_eMsgId, _nm_msg_def_struct::m_pFields, _nm_field_def_struct::m_uOffset, NM_ECODE_FTYPE, NM_ECODE_NOMEM, NMFTypePad, NMLIB_ASCII_FTYPE, NMLIB_RAISE_ERROR, NMLIB_RAISE_FIELD_ERROR, and nmLookupFlatPacker().

Referenced by nmPackFlatMsg(), nmPackFlatMsgDebug(), and nmPackFlatStruct().

696 {
697  size_t uFieldNum; // field instance number (not id)
698  const NMFieldDef_T *pFieldDef; // working field definition pointer
699  NMPackFunc_T fnPack; // field packing function
700  void *pVal; // pointer to field value
701  int n = 0; // byte count/error code
702  int k; // subbyte count/error code
703 
704  //
705  // Pack message fields
706  //
707  for(uFieldNum=0, pFieldDef=pMsgDef->m_pFields;
708  uFieldNum < pMsgDef->m_uCount;
709  ++uFieldNum, ++pFieldDef)
710  {
711  if( n < bufSize )
712  {
713  if( pFieldDef->m_eFType == NMFTypePad )
714  {
715  pVal = NULL;
716  }
717 
718  else
719  {
720  pVal = pStruct + pFieldDef->m_uOffset;
721  }
722 
723  fnPack = nmLookupFlatPacker(pFieldDef->m_eFType);
724 
725  if( fnPack == NULL )
726  {
728  "ftype='%c'(0x%02x).",
729  NMLIB_ASCII_FTYPE(pFieldDef->m_eFType), pFieldDef->m_eFType);
730  }
731 
732  k = fnPack(pFieldDef, pVal, &buf[n], bufSize-(size_t)n, eEndian, pCtl);
733 
734  if( k < 0 )
735  {
736  return k;
737  }
738  }
739 
740  else
741  {
743  "buf_size=%zu, msgid=%u", bufSize, pMsgDef->m_eMsgId);
744  }
745 
746  n += k;
747  }
748 
749  return n;
750 }
#define NM_ECODE_FTYPE
unknown field type
Definition: netmsgs.h:76
static NMPackFunc_T nmLookupFlatPacker(NMFType_T eFType)
Lookup Flat packer function, given the message field type.
NMFType_T m_eFType
field type
Definition: netmsgs.h:383
uint_t m_eMsgId
message id (globally unique)
Definition: netmsgs.h:407
#define NMLIB_RAISE_ERROR(ecode, fmt,...)
Raise libnetmsgs error (i.e. return from calling function).
#define NM_ECODE_NOMEM
not enough buffer memory available
Definition: netmsgs.h:73
int(* NMPackFunc_T)(const NMFieldDef_T *, void *, byte_t[], size_t, NMEndian_T, NMCtl_T *)
const NMFieldDef_T * m_pFields
pointer to array of msg field definitions
Definition: netmsgs.h:409
pad internal field type
Definition: netmsgs.h:145
#define NMLIB_RAISE_FIELD_ERROR(ecode, p, fmt,...)
Raise libnetmsgs field error (i.e. return from calling function).
#define NMLIB_ASCII_FTYPE(ftype)
Printable ASCII Field Type.
size_t m_uOffset
member offset in assoc msg structure
Definition: netmsgs.h:384
static int nmPackFlatString ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack null-terminated, fixed length string Flat field into the message buffer.

Note
The null character is not packed.
Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 497 of file nmLibPackFlat.c.

References NMFieldThisString_T::m_sConst, NMFieldThis_T::m_string, _nm_field_def_struct::m_this, NMFieldThisString_T::m_uMaxCount, NM_ECODE_NOMEM, NM_ECODE_RANGE, NMLIB_RAISE_FIELD_ERROR, and NMLIB_TRACE_FIELD.

503 {
504  const char *sVal; // string field value pointer
505  const char *sConst; // string constant value, if any
506  size_t uMaxCount; // string maximum packed size
507  size_t uCount; // string length
508 
509  sVal = (const char *)pVal; // override void *
510  sConst = pFieldDef->m_this.m_string.m_sConst;
511  uMaxCount = pFieldDef->m_this.m_string.m_uMaxCount;
512 
513  if( sConst != NULL )
514  {
515  sVal = sConst;
516  }
517 
518  uCount = strlen(sVal); // string length w/o null
519 
520  // string length exceeds maximum
521  if( uCount > uMaxCount )
522  {
524  "char_count=%zu > max_count=%zu.", uCount, uMaxCount);
525  }
526 
527  // no more space in buffer for string
528  else if( uMaxCount > bufSize )
529  {
531  "buf_size=%zu < str_max_len=%zu.", bufSize, uMaxCount);
532  }
533 
534  // copy string field value
535  memcpy(buf, sVal, uCount);
536 
537  // pad with zeros
538  if( uCount < uMaxCount )
539  {
540  memset(&buf[uCount], 0, uMaxCount-uCount);
541  }
542 
543  NMLIB_TRACE_FIELD(pFieldDef, buf, uMaxCount, pCtl, "'%s'", sVal);
544 
545  return (int)uMaxCount;
546 }
NMFieldThisString_T m_string
string field specific info
Definition: netmsgs.h:371
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
NMFieldThis_T m_this
specific field information
Definition: netmsgs.h:385
size_t m_uMaxCount
maximum number of characters sans null char
Definition: netmsgs.h:339
#define NM_ECODE_NOMEM
not enough buffer memory available
Definition: netmsgs.h:73
const char * m_sConst
string constant value (NULL if no const)
Definition: netmsgs.h:340
#define NMLIB_RAISE_FIELD_ERROR(ecode, p, fmt,...)
Raise libnetmsgs field error (i.e. return from calling function).
#define NM_ECODE_RANGE
field size or value out-of-range
Definition: netmsgs.h:75
static int nmPackFlatStruct ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack a structure Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 554 of file nmLibPackFlat.c.

References _nm_msg_def_struct::m_sMsgName, NMFieldThis_T::m_struct, _nm_field_def_struct::m_this, _nm_msg_def_struct::m_uCount, NMCtl_T::m_uDepth, NMLIB_TRACE_FIELD, and nmPackFlatStream().

560 {
561  const NMMsgDef_T *pStructDef; // pointer to structure message definition
562  int n; // byte count/error code
563 
564  pStructDef = pFieldDef->m_this.m_struct;
565 
566  NMLIB_TRACE_FIELD(pFieldDef, buf, 0, pCtl, "structdef %s, member_count=%zu",
567  pStructDef->m_sMsgName, pStructDef->m_uCount);
568 
569  pCtl->m_uDepth++;
570 
571  // copy struct field value
572  n = nmPackFlatStream(pStructDef, pVal, buf, bufSize, eEndian, pCtl);
573 
574  pCtl->m_uDepth--;
575 
576  return n;
577 }
byte_t m_uDepth
structured message depth
static int nmPackFlatStream(const NMMsgDef_T *pMsgDef, void *pStruct, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a Flat message.
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
size_t m_uCount
number of message fields
Definition: netmsgs.h:408
NMFieldThisStruct_T m_struct
struct field specific info
Definition: netmsgs.h:372
NMFieldThis_T m_this
specific field information
Definition: netmsgs.h:385
const char * m_sMsgName
message/struct string name
Definition: netmsgs.h:406
static int nmPackFlatU16 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack an unsigned 16-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 206 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackU16(), and nmSetU16().

212 {
213  ushort_t val; // constrained field value
214  int n; // byte count/error code
215 
216  // try to set field value
217  if( (n = nmSetU16(pFieldDef, pVal, &val)) != NM_OK )
218  {
219  return n;
220  }
221 
222  // pack field value
223  n = nmPackU16(val, buf, bufSize, eEndian);
224 
225  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%hu", val);
226 
227  return n;
228 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
int nmPackU16(ushort_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack an unsigned 16-bit integer into the message buffer.
Definition: nmLibPack.c:762
int nmSetU16(const NMFieldDef_T *pFieldDef, void *pValIn, ushort_t *pValOut)
Helper function to set an unsigned 16-bit integer.
static int nmPackFlatU32 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack an unsigned 32-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 266 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackU32(), and nmSetU32().

272 {
273  uint_t val; // constrained field value
274  int n; // byte count/error code
275 
276  // set field value
277  if( (n = nmSetU32(pFieldDef, pVal, &val)) != NM_OK )
278  {
279  return n;
280  }
281 
282  // pack field value
283  n = nmPackU32(val, buf, bufSize, eEndian);
284 
285  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%u", val);
286 
287  return n;
288 }
int nmSetU32(const NMFieldDef_T *pFieldDef, void *pValIn, uint_t *pValOut)
Helper function to set an unsigned 32-bit integer.
int nmPackU32(uint_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack an unsigned 32-bit integer into the message buffer.
Definition: nmLibPack.c:791
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
static int nmPackFlatU64 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack an unsigned 64-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 326 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackU64(), and nmSetU64().

332 {
333  ulonglong_t val; // constrained field value
334  int n; // byte count/error code
335 
336  // set field value
337  if( (n = nmSetU64(pFieldDef, pVal, &val)) != NM_OK )
338  {
339  return n;
340  }
341 
342  // pack field value
343  n = nmPackU64(val, buf, bufSize, eEndian);
344 
345  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%llu", val);
346 
347  return n;
348 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
int nmSetU64(const NMFieldDef_T *pFieldDef, void *pValIn, ulonglong_t *pValOut)
Helper function to set an unsigned 64-bit integer.
int nmPackU64(ulonglong_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack an unsigned 64-bit integer into the message buffer.
Definition: nmLibPack.c:823
static int nmPackFlatU8 ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack an unsigned 8-bit Flat field into the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 146 of file nmLibPackFlat.c.

References NM_OK, NMLIB_TRACE_FIELD, nmPackU8(), and nmSetU8().

152 {
153  byte_t val; // constrained field value
154  int n; // byte count/error code
155 
156  // try to set field value
157  if( (n = nmSetU8(pFieldDef, pVal, &val)) != NM_OK )
158  {
159  return n;
160  }
161 
162  // pack field value
163  n = nmPackU8(val, buf, bufSize, eEndian);
164 
165  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%hhu", val);
166 
167  return n;
168 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
#define NM_OK
not an error, success
Definition: netmsgs.h:70
int nmPackU8(byte_t val, byte_t buf[], size_t bufSize, NMEndian_T eEndian)
Pack an unsigned 8-bit byte into the message buffer.
Definition: nmLibPack.c:745
int nmSetU8(const NMFieldDef_T *pFieldDef, void *pValIn, byte_t *pValOut)
Helper function to set an unsigned 8-bit integer.
static int nmPackFlatVector ( const NMFieldDef_T pFieldDef,
void *  pVal,
byte_t  buf[],
size_t  bufSize,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Pack variable length vector Flat field into the message buffer.

A vector is a one-dimension array of the given type.

Parameters
pFieldDefPointer to message field definition.
[in]pValPointer to (typecasted) value to pack.
[out]bufOutput message buffer.
bufSizeSize of output buffer.
eEndianPacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes packed. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 587 of file nmLibPackFlat.c.

References NMCtl_T::m_bNoHdr, NMVec_T::m_buf, _nm_field_def_struct::m_eFType, NMFieldThisVector_T::m_pThisElem, _nm_field_def_struct::m_this, NMVec_T::m_uCount, NMCtl_T::m_uDepth, NMFieldThisVector_T::m_uElemSize, NMFieldThisVector_T::m_uMaxCount, NMFieldThis_T::m_vector, NM_ECODE_FTYPE, NM_ECODE_NOMEM, NM_ECODE_RANGE, NMFTYPE_IS_SIMPLE, NMLIB_ASCII_FTYPE, NMLIB_RAISE_FIELD_ERROR, NMLIB_TRACE_FIELD, and nmLookupFlatPacker().

593 {
594  size_t uMaxCount; // vector maximum number of elements
595  size_t uElemSize; // vector element size
596  const NMFieldDef_T *pElemDef; // vector element field definition
597  NMVec_T *pVec; // pointer to vector field template
598  size_t uCount; // number of vector items to pack
599  byte_t *pItem; // working vector item pointer
600  NMPackFunc_T fnPack; // vector item packing function
601  int n; // byte count/error code
602  int k; // subbyte count/error code
603  size_t i; // working vector index
604 
605  uMaxCount = pFieldDef->m_this.m_vector.m_uMaxCount;
606  uElemSize = pFieldDef->m_this.m_vector.m_uElemSize;
607  pElemDef = pFieldDef->m_this.m_vector.m_pThisElem;
608  pVec = (NMVec_T *)pVal; // generalized vector overlay
609  uCount = pVec->m_uCount; // number of vector items
610  pItem = (byte_t *)(pVec) + memberoffset(NMVec_T, u.m_buf);
611  fnPack = nmLookupFlatPacker(pElemDef->m_eFType);
612 
613  if( fnPack == NULL )
614  {
616  "vector_elem_ftype='%c'(0x%02x)",
617  NMLIB_ASCII_FTYPE(pElemDef->m_eFType), pElemDef->m_eFType);
618  }
619 
620  // exceeds maximum
621  else if( uCount > uMaxCount )
622  {
624  "vector_count=%zu > vector_max_count=%zu.", uCount, uMaxCount);
625  }
626 
627  NMLIB_TRACE_FIELD(pFieldDef, buf, 0, pCtl, "%c:vector[%zu], max_count=%zu",
628  pElemDef->m_eFType, uCount, uMaxCount);
629 
630  // no header for simple vector element types
631  if( NMFTYPE_IS_SIMPLE(pElemDef->m_eFType) )
632  {
633  pCtl->m_bNoHdr = true;
634  }
635 
636  pCtl->m_uDepth++;
637 
638  // copy vector field value
639  for(i=0, n=0; i<uCount; ++i)
640  {
641  k = fnPack(pElemDef, pItem, &buf[n], bufSize-(size_t)n, eEndian, pCtl);
642 
643  if( k < 0 )
644  {
645  return k;
646  }
647 
648  n += k;
649 
650  pItem += uElemSize;
651  }
652 
653  // pad out fixed size vector with zero's.
654  if( uCount < uMaxCount )
655  {
656  i = (uMaxCount - uCount) * uElemSize;
657 
658  if( i > bufSize-(size_t)n)
659  {
661  "buf_size=%zu < vector_pad_size=%zu", bufSize-(size_t)n, i);
662  }
663 
664  else
665  {
666  memset(&buf[n], 0, i);
667  n += (int)i;
668  }
669  }
670 
671  pCtl->m_uDepth--;
672  pCtl->m_bNoHdr = false;
673 
674  return n;
675 }
byte_t m_bNoHdr
do [not] include field header in byte stream
byte_t m_uDepth
structured message depth
size_t m_uMaxCount
maximum number of vector elements
Definition: netmsgs.h:354
NMFieldThisVector_T m_vector
vector field specific info
Definition: netmsgs.h:373
#define NM_ECODE_FTYPE
unknown field type
Definition: netmsgs.h:76
static NMPackFunc_T nmLookupFlatPacker(NMFType_T eFType)
Lookup Flat packer function, given the message field type.
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
NMFType_T m_eFType
field type
Definition: netmsgs.h:383
#define NMFTYPE_IS_SIMPLE(ft)
Returns true if field type is a simple type.
Definition: netmsgs.h:164
NMFieldThis_T m_this
specific field information
Definition: netmsgs.h:385
#define NM_ECODE_NOMEM
not enough buffer memory available
Definition: netmsgs.h:73
int(* NMPackFunc_T)(const NMFieldDef_T *, void *, byte_t[], size_t, NMEndian_T, NMCtl_T *)
NMFieldDef_P m_pThisElem
vector element specific info
Definition: netmsgs.h:356
size_t m_uElemSize
vector element storage size
Definition: netmsgs.h:355
size_t m_uCount
number of items in vector
Definition: netmsgs.h:393
#define NMLIB_RAISE_FIELD_ERROR(ecode, p, fmt,...)
Raise libnetmsgs field error (i.e. return from calling function).
#define NMLIB_ASCII_FTYPE(ftype)
Printable ASCII Field Type.
#define NM_ECODE_RANGE
field size or value out-of-range
Definition: netmsgs.h:75
byte_t * m_buf
the vector
Definition: netmsgs.h:397
static int nmUnpackFlatBool ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack an unsigned 8-bit boolean Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 793 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackBool().

799 {
800  int n; // byte count/error code
801 
802  // unpack value
803  n = nmUnpackBool(buf, bufSize, pVal, eEndian);
804 
805  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%s",
806  (*((bool_t *)pVal)? "true": "false"));
807 
808  return n;
809 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
INLINE_IN_H int nmUnpackBool(byte_t buf[], size_t bufSize, bool_t *pVal, NMEndian_T eEndian)
Unpack a boolean value from the message buffer.
Definition: netmsgs.h:823
static int nmUnpackFlatF32 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack a 32-bit floating-point number Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1002 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackF32().

1008 {
1009  int n; // byte count/error code
1010 
1011  // unpack value
1012  n = nmUnpackF32(buf, bufSize, pVal, eEndian);
1013 
1014  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%f", *((float *)pVal));
1015 
1016  return n;
1017 }
int nmUnpackF32(byte_t buf[], size_t bufSize, float *pVal, NMEndian_T eEndian)
Unpack a 32-bit float from the message buffer.
Definition: nmLibPack.c:1472
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
static int nmUnpackFlatF64 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack a 64-bit floating-point number Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1026 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackF64().

1032 {
1033  int n; // byte count/error code
1034 
1035  // unpack value
1036  n = nmUnpackF64(buf, bufSize, pVal, eEndian);
1037 
1038  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%e", *((double *)pVal));
1039 
1040  return n;
1041 }
int nmUnpackF64(byte_t buf[], size_t bufSize, double *pVal, NMEndian_T eEndian)
Unpack a 64-bit float from the message buffer.
Definition: nmLibPack.c:1517
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
int nmUnpackFlatMsg ( const NMMsgDef_T pMsgDef,
byte_t  buf[],
size_t  uMsgLen,
void *  pStruct,
NMEndian_T  eEndian 
)

Unpack a Flat message.

Parameters
pMsgDefPointer to message definition.
[in]bufInput message buffer.
uMsgLenLength of message (bytes) in input buffer.
[out]pStructPointer to the associated message structure to populate.
eEndianUnpacking order. See NMEndian_T.
Returns
On success, returns the number of bytes unpacked. On error, returns < 0.

Definition at line 1490 of file nmLibPackFlat.c.

References NMCtl_T::m_bNoHdr, NMCTL_INIT_DECL, and nmUnpackFlatStream().

Referenced by nmUnpackPointer().

1495 {
1496  NMCtl_T ctl = NMCTL_INIT_DECL;
1497  int n; // byte count/error code
1498 
1499  ctl.m_bNoHdr = true;
1500 
1501  // unpack stream
1502  n = nmUnpackFlatStream(pMsgDef, buf, uMsgLen, pStruct, eEndian, &ctl);
1503 
1504  // return code
1505  return n;
1506 }
byte_t m_bNoHdr
do [not] include field header in byte stream
static int nmUnpackFlatStream(const NMMsgDef_T *pMsgDef, byte_t buf[], size_t uMsgLen, void *pStruct, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack an Flat byte stream.
#define NMCTL_INIT_DECL
Default Internal control declartion list.
Internal Control Structure.
int nmUnpackFlatMsgDebug ( const NMMsgDef_T pMsgDef,
byte_t  buf[],
size_t  uMsgLen,
void *  pStruct,
NMEndian_T  eEndian 
)

Unpack a Flat message, tracing unpacking to stderr.

Parameters
pMsgDefPointer to message definition.
[in]bufInput message buffer.
uMsgLenLength of message (bytes) in input buffer.
[out]pStructPointer to the associated message structure to populate.
eEndianUnpacking order. See NMEndian_T.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1520 of file nmLibPackFlat.c.

References NMCtl_T::m_bNoHdr, NMCtl_T::m_bTrace, _nm_msg_def_struct::m_eMsgId, _nm_msg_def_struct::m_sMsgName, _nm_msg_def_struct::m_uCount, NMCTL_INIT_DECL, nmPrintBuf(), and nmUnpackFlatStream().

Referenced by nmUnpackPointer().

1525 {
1526  NMCtl_T ctl = NMCTL_INIT_DECL;
1527  int n; // byte count/error code
1528 
1529  ctl.m_bNoHdr = true;
1530  ctl.m_bTrace = true;
1531 
1532  // trace
1533  fprintf(stderr, "\n--- Unpacking Flat Message %s(%u): field_count=%zu\n",
1534  pMsgDef->m_sMsgName, pMsgDef->m_eMsgId, pMsgDef->m_uCount);
1535  fprintf(stderr, "Input Buffer (%zu bytes):\n", uMsgLen);
1536  nmPrintBuf(stderr, NULL, buf, uMsgLen, 16, 0);
1537  fprintf(stderr, "\n");
1538 
1539  // unpack stream
1540  n = nmUnpackFlatStream(pMsgDef, buf, uMsgLen, pStruct, eEndian, &ctl);
1541 
1542  // return code
1543  return n;
1544 }
byte_t m_bNoHdr
do [not] include field header in byte stream
byte_t m_bTrace
do [not] trace packing/unpacking
uint_t m_eMsgId
message id (globally unique)
Definition: netmsgs.h:407
size_t m_uCount
number of message fields
Definition: netmsgs.h:408
static int nmUnpackFlatStream(const NMMsgDef_T *pMsgDef, byte_t buf[], size_t uMsgLen, void *pStruct, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack an Flat byte stream.
#define NMCTL_INIT_DECL
Default Internal control declartion list.
const char * m_sMsgName
message/struct string name
Definition: netmsgs.h:406
void nmPrintBuf(FILE *fp, const char *sPreface, byte_t buf[], size_t uCount, size_t uNLFreq, uint_t uCol)
Pretty print buffer to opened file stream.
Definition: nmLibUtils.c:138
Internal Control Structure.
static int nmUnpackFlatP32 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack a 32-bit pointer Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1049 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackP32().

1055 {
1056  int n; // byte count/error code
1057 
1058  // unpack value
1059  n = nmUnpackP32(buf, bufSize, pVal, eEndian);
1060 
1061  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%p", *((ulong_t *)pVal));
1062 
1063  return n;
1064 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
int nmUnpackP32(byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian)
Unpack a 32-bit pointer from the message buffer.
Definition: nmLibPack.c:1648
static int nmUnpackFlatP64 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack a 64-bit pointer Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1072 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackP64().

1078 {
1079  int n; // byte count/error code
1080 
1081  // unpack value
1082  n = nmUnpackP64(buf, bufSize, pVal, eEndian);
1083 
1084  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%p", *((ulong_t *)pVal));
1085 
1086  return n;
1087 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
int nmUnpackP64(byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian)
Unpack a 64-bit pointer from the message buffer.
Definition: nmLibPack.c:1678
static int nmUnpackFlatPad ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack pad byte from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 763 of file nmLibPackFlat.c.

References _nm_field_def_struct::m_eFId, NMFieldThis_T::m_pad, _nm_field_def_struct::m_this, NMFieldThisPad_T::m_uCount, NM_ECODE_NOMEM, NMLIB_RAISE_FIELD_ERROR, and NMLIB_TRACE_FIELD.

769 {
770  size_t uCount = pFieldDef->m_this.m_pad.m_uCount;
771 
772  // unpack pad bytes
773  if( uCount <= bufSize )
774  {
775  NMLIB_TRACE_FIELD(NULL, buf, uCount, pCtl, "pad(%u)", pFieldDef->m_eFId);
776  return (int)uCount;
777  }
778 
779  // no more space in buffer for pad bytes
780  else
781  {
783  "buf_size=%zu < pad_count=%zu", bufSize, uCount);
784  }
785 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
NMFieldThis_T m_this
specific field information
Definition: netmsgs.h:385
#define NM_ECODE_NOMEM
not enough buffer memory available
Definition: netmsgs.h:73
size_t m_uCount
number of pad bytes
Definition: netmsgs.h:265
#define NMLIB_RAISE_FIELD_ERROR(ecode, p, fmt,...)
Raise libnetmsgs field error (i.e. return from calling function).
NMFieldThisPad_T m_pad
pad field specific info
Definition: netmsgs.h:364
uint_t m_eFId
filed id (message/struct unique)
Definition: netmsgs.h:382
static int nmUnpackFlatS16 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack a signed 16-bit Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 886 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackS16().

892 {
893  int n; // byte count/error code
894 
895  // unpack value
896  n = nmUnpackS16(buf, bufSize, pVal, eEndian);
897 
898  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%hd", *((short *)pVal));
899 
900  return n;
901 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
INLINE_IN_H int nmUnpackS16(byte_t buf[], size_t bufSize, short *pVal, NMEndian_T eEndian)
Unpack a signed 16-bit integer from the message buffer.
Definition: netmsgs.h:759
static int nmUnpackFlatS32 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack a signed 32-bit Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 932 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackS32().

938 {
939  int n; // byte count/error code
940 
941  // unpack value
942  n = nmUnpackS32(buf, bufSize, pVal, eEndian);
943 
944  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%d", *((int *)pVal));
945 
946  return n;
947 }
INLINE_IN_H int nmUnpackS32(byte_t buf[], size_t bufSize, int *pVal, NMEndian_T eEndian)
Unpack a signed 32-bit integer from the message buffer.
Definition: netmsgs.h:771
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
static int nmUnpackFlatS64 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack a signed 64-bit Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 978 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackS64().

984 {
985  int n; // byte count/error code
986 
987  // unpack value
988  n = nmUnpackS64(buf, bufSize, pVal, eEndian);
989 
990  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%lld", *((long long *)pVal));
991 
992  return n;
993 }
int nmUnpackS64(byte_t buf[], size_t bufSize, long long *pVal, NMEndian_T eEndian)
Unpack an signed 64-bit integer from the message buffer.
Definition: nmLibPack.c:1391
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
static int nmUnpackFlatS8 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack a signed 8-bit Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 840 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackS8().

846 {
847  int n; // byte count/error code
848 
849  // unpack value
850  n = nmUnpackS8(buf, bufSize, pVal, eEndian);
851 
852  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%hhd", *((signed char *)pVal));
853 
854  return n;
855 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
INLINE_IN_H int nmUnpackS8(byte_t buf[], size_t bufSize, signed char *pVal, NMEndian_T eEndian)
Unpack a signed 8-bit byte from the message buffer.
Definition: netmsgs.h:747
static int nmUnpackFlatStream ( const NMMsgDef_T pMsgDef,
byte_t  buf[],
size_t  uMsgLen,
void *  pStruct,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack an Flat byte stream.

Parameters
pMsgDefPointer to message definition.
[in]bufInput message buffer.
uMsgLenLength of message (bytes) in input buffer.
[out]pStructPointer to the associated message structure to populate.
eEndianUnpacking order. See NMEndian_T.
pCtlPointer to Internal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1239 of file nmLibPackFlat.c.

References _nm_field_def_struct::m_eFType, _nm_msg_def_struct::m_eMsgId, _nm_msg_def_struct::m_pFields, _nm_field_def_struct::m_uOffset, NM_ECODE_FTYPE, NM_ECODE_NOMEM, NMFTypePad, NMLIB_ASCII_FTYPE, NMLIB_RAISE_ERROR, NMLIB_RAISE_FIELD_ERROR, and nmLookupFlatUnpacker().

Referenced by nmUnpackFlatMsg(), nmUnpackFlatMsgDebug(), and nmUnpackFlatStruct().

1245 {
1246  size_t uFieldNum; // field instance number (not id)
1247  const NMFieldDef_T *pFieldDef; // working field definition pointer
1248  NMUnpackFunc_T fnUnpack; // field unpack function
1249  void *pVal; // pointer to field value
1250  int n = 0; // byte count/error code
1251  int k; // subbyte count/error code
1252 
1253  for(uFieldNum=0, pFieldDef=pMsgDef->m_pFields;
1254  uFieldNum < pMsgDef->m_uCount;
1255  ++uFieldNum, ++pFieldDef)
1256  {
1257  if( n < uMsgLen )
1258  {
1259  if( pFieldDef->m_eFType == NMFTypePad )
1260  {
1261  pVal = NULL;
1262  }
1263 
1264  else
1265  {
1266  pVal = pStruct + pFieldDef->m_uOffset;
1267  }
1268 
1269  fnUnpack = nmLookupFlatUnpacker(pFieldDef->m_eFType);
1270 
1271  if( fnUnpack == NULL )
1272  {
1274  "ftype='%c'(0x%02x).",
1275  NMLIB_ASCII_FTYPE(pFieldDef->m_eFType), pFieldDef->m_eFType);
1276  }
1277 
1278  k = fnUnpack(pFieldDef, &buf[n], uMsgLen-(size_t)n, pVal, eEndian, pCtl);
1279 
1280  if( k < 0 )
1281  {
1282  return k;
1283  }
1284  }
1285 
1286  else
1287  {
1289  "buf_size=%zu, msgid=%u", uMsgLen, pMsgDef->m_eMsgId);
1290  }
1291 
1292  n += k;
1293  }
1294 
1295  return n;
1296 }
#define NM_ECODE_FTYPE
unknown field type
Definition: netmsgs.h:76
NMFType_T m_eFType
field type
Definition: netmsgs.h:383
uint_t m_eMsgId
message id (globally unique)
Definition: netmsgs.h:407
int(* NMUnpackFunc_T)(const NMFieldDef_T *, byte_t[], size_t, void *, NMEndian_T, NMCtl_T *)
#define NMLIB_RAISE_ERROR(ecode, fmt,...)
Raise libnetmsgs error (i.e. return from calling function).
static NMUnpackFunc_T nmLookupFlatUnpacker(NMFType_T eFType)
Lookup Flat unpacker function, given the message field type.
#define NM_ECODE_NOMEM
not enough buffer memory available
Definition: netmsgs.h:73
const NMFieldDef_T * m_pFields
pointer to array of msg field definitions
Definition: netmsgs.h:409
pad internal field type
Definition: netmsgs.h:145
#define NMLIB_RAISE_FIELD_ERROR(ecode, p, fmt,...)
Raise libnetmsgs field error (i.e. return from calling function).
#define NMLIB_ASCII_FTYPE(ftype)
Printable ASCII Field Type.
size_t m_uOffset
member offset in assoc msg structure
Definition: netmsgs.h:384
static int nmUnpackFlatString ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack variable length string Flat field from the message buffer.

Note
The null character is appended to the end of the unpacked value.
Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1097 of file nmLibPackFlat.c.

References NMFieldThis_T::m_string, _nm_field_def_struct::m_this, NMFieldThisString_T::m_uMaxCount, NM_ECODE_NOMEM, NMLIB_RAISE_FIELD_ERROR, and NMLIB_TRACE_FIELD.

1103 {
1104  size_t uMaxCount; // maximum string length
1105  char *sVal; // string pointer
1106 
1107  // field definition and derived values
1108  uMaxCount = pFieldDef->m_this.m_string.m_uMaxCount;
1109  sVal = (char *)pVal;
1110 
1111  if( uMaxCount > bufSize )
1112  {
1114  "buf_size=%zu, max_count=%zu", bufSize, uMaxCount);
1115  }
1116 
1117  memcpy(sVal, buf, uMaxCount);
1118  sVal[uMaxCount] = 0;
1119 
1120  NMLIB_TRACE_FIELD(pFieldDef, buf, uMaxCount, pCtl, "'%s'", sVal);
1121 
1122  return (int)uMaxCount;
1123 }
NMFieldThisString_T m_string
string field specific info
Definition: netmsgs.h:371
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
NMFieldThis_T m_this
specific field information
Definition: netmsgs.h:385
size_t m_uMaxCount
maximum number of characters sans null char
Definition: netmsgs.h:339
#define NM_ECODE_NOMEM
not enough buffer memory available
Definition: netmsgs.h:73
#define NMLIB_RAISE_FIELD_ERROR(ecode, p, fmt,...)
Raise libnetmsgs field error (i.e. return from calling function).
static int nmUnpackFlatStruct ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack structure Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1132 of file nmLibPackFlat.c.

References _nm_msg_def_struct::m_sMsgName, NMFieldThis_T::m_struct, _nm_field_def_struct::m_this, _nm_msg_def_struct::m_uCount, NMCtl_T::m_uDepth, NMLIB_TRACE_FIELD, and nmUnpackFlatStream().

1138 {
1139  const NMMsgDef_T *pStructDef; // structure definition
1140  int n; // byte count/error code
1141 
1142  pStructDef = pFieldDef->m_this.m_struct;
1143 
1144  NMLIB_TRACE_FIELD(pFieldDef, buf, 0, pCtl, "structdef %s, member_count=%zu",
1145  pStructDef->m_sMsgName, pStructDef->m_uCount);
1146 
1147  pCtl->m_uDepth++;
1148 
1149  // copy struct field value
1150  n = nmUnpackFlatStream(pStructDef, buf, bufSize, pVal, eEndian, pCtl);
1151 
1152  pCtl->m_uDepth--;
1153 
1154  return n;
1155 }
byte_t m_uDepth
structured message depth
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
size_t m_uCount
number of message fields
Definition: netmsgs.h:408
NMFieldThisStruct_T m_struct
struct field specific info
Definition: netmsgs.h:372
static int nmUnpackFlatStream(const NMMsgDef_T *pMsgDef, byte_t buf[], size_t uMsgLen, void *pStruct, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack an Flat byte stream.
NMFieldThis_T m_this
specific field information
Definition: netmsgs.h:385
const char * m_sMsgName
message/struct string name
Definition: netmsgs.h:406
static int nmUnpackFlatU16 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack an unsigned 16-bit Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 863 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackU16().

869 {
870  int n; // byte count/error code
871 
872  // unpack value
873  n = nmUnpackU16(buf, bufSize, pVal, eEndian);
874 
875  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%hu", *((ushort_t *)pVal));
876 
877  return n;
878 }
int nmUnpackU16(byte_t buf[], size_t bufSize, ushort_t *pVal, NMEndian_T eEndian)
Unpack an unsigned 16-bit integer from the message buffer.
Definition: nmLibPack.c:1256
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
static int nmUnpackFlatU32 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack an unsigned 32-bit Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 909 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackU32().

915 {
916  int n; // byte count/error code
917 
918  // unpack value
919  n = nmUnpackU32(buf, bufSize, pVal, eEndian);
920 
921  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%u", *((uint_t *)pVal));
922 
923  return n;
924 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
int nmUnpackU32(byte_t buf[], size_t bufSize, uint_t *pVal, NMEndian_T eEndian)
Unpack an unsigned 32-bit integer from the message buffer.
Definition: nmLibPack.c:1288
static int nmUnpackFlatU64 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack an unsigned 64-bit Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 955 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackU64().

961 {
962  int n; // byte count/error code
963 
964  // unpack value
965  n = nmUnpackU64(buf, bufSize, pVal, eEndian);
966 
967  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%llu", *((ulonglong_t *)pVal));
968 
969  return n;
970 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
int nmUnpackU64(byte_t buf[], size_t bufSize, ulonglong_t *pVal, NMEndian_T eEndian)
Unpack an unsigned 64-bit integer from the message buffer.
Definition: nmLibPack.c:1320
static int nmUnpackFlatU8 ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack an unsigned 8-bit Flat field from the message buffer.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 817 of file nmLibPackFlat.c.

References NMLIB_TRACE_FIELD, and nmUnpackU8().

823 {
824  int n; // byte count/error code
825 
826  // unpack value
827  n = nmUnpackU8(buf, bufSize, pVal, eEndian);
828 
829  NMLIB_TRACE_FIELD(pFieldDef, buf, n, pCtl, "%hhu", *((byte_t *)pVal));
830 
831  return n;
832 }
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
int nmUnpackU8(byte_t buf[], size_t bufSize, byte_t *pVal, NMEndian_T eEndian)
Unpack an unsigned 8-bit byte from the message buffer.
Definition: nmLibPack.c:1239
static int nmUnpackFlatVector ( const NMFieldDef_T pFieldDef,
byte_t  buf[],
size_t  bufSize,
void *  pVal,
NMEndian_T  eEndian,
NMCtl_T pCtl 
)
static

Unpack variable length vector Flat field from the message buffer.

A vector is a one-dimension array of the given type.

Parameters
pFieldDefPointer to message field definition.
[in]bufInput message buffer.
bufSizeSize of input buffer.
[out]pValPointer to value to unpack (set).
eEndianUnpacking order. See NMEndian_T.
pCtlInternal control.
Returns
On success, returns the number of bytes unpacked. On error, the appropriate negated netmsgs error code ( < 0) is returned.

Definition at line 1165 of file nmLibPackFlat.c.

References NMVec_T::m_buf, _nm_field_def_struct::m_eFType, NMFieldThisVector_T::m_pThisElem, _nm_field_def_struct::m_this, NMCtl_T::m_uDepth, NMFieldThisVector_T::m_uElemSize, NMFieldThisVector_T::m_uMaxCount, NMFieldThis_T::m_vector, NM_ECODE_FTYPE, NMLIB_ASCII_FTYPE, NMLIB_RAISE_FIELD_ERROR, NMLIB_TRACE_FIELD, and nmLookupFlatUnpacker().

1171 {
1172  size_t uMaxCount; // vector maximum number of elements
1173  size_t uElemSize; // vector element size
1174  const NMFieldDef_T *pElemDef; // vector element field definition
1175  NMVec_T *pVec; // pointer to vector field template
1176  byte_t *pItem; // working vector item pointer
1177  NMFType_T eVType; // vector itim field type
1178  NMUnpackFunc_T fnUnpack; // vector item unpacking function
1179  int n; // byte count/error code
1180  int k; // subbyte count/error code
1181  size_t i; // working vector index
1182 
1183  // field definition and derived values
1184  uMaxCount = pFieldDef->m_this.m_vector.m_uMaxCount;
1185  uElemSize = pFieldDef->m_this.m_vector.m_uElemSize;
1186  pElemDef = pFieldDef->m_this.m_vector.m_pThisElem;
1187  pVec = (NMVec_T *)pVal; // generalized vector overlay
1188  pItem = (byte_t *)(pVec) + memberoffset(NMVec_T, u.m_buf);
1189  eVType = pElemDef->m_eFType;
1190  fnUnpack = nmLookupFlatUnpacker(eVType);
1191 
1192  // no unpacker
1193  if( fnUnpack == NULL )
1194  {
1196  "vector_elem_ftype='%c'(0x%02x).",
1197  NMLIB_ASCII_FTYPE(pElemDef->m_eFType), eVType);
1198  }
1199 
1200  NMLIB_TRACE_FIELD(pFieldDef, buf, 0, pCtl,
1201  "vector_max_count=%zu, vector_elem_ftype='%c'(0x%02x)",
1202  uMaxCount, NMLIB_ASCII_FTYPE(eVType), eVType);
1203 
1204  pCtl->m_uDepth++;
1205 
1206  // unpack field into vector field
1207  for(i=0, n=0; i<uMaxCount; ++i)
1208  {
1209  k = fnUnpack(pElemDef, &buf[n], bufSize-(size_t)n, pItem, eEndian, pCtl);
1210 
1211  if( k < 0 )
1212  {
1213  return k;
1214  }
1215 
1216  n += k;
1217 
1218  pItem += uElemSize;
1219  }
1220 
1221  pCtl->m_uDepth--;
1222 
1223  return n;
1224 }
byte_t m_uDepth
structured message depth
size_t m_uMaxCount
maximum number of vector elements
Definition: netmsgs.h:354
NMFieldThisVector_T m_vector
vector field specific info
Definition: netmsgs.h:373
#define NM_ECODE_FTYPE
unknown field type
Definition: netmsgs.h:76
#define NMLIB_TRACE_FIELD(p, buf, n, ctl, fmt,...)
Trace field.
NMFType_T m_eFType
field type
Definition: netmsgs.h:383
int(* NMUnpackFunc_T)(const NMFieldDef_T *, byte_t[], size_t, void *, NMEndian_T, NMCtl_T *)
static NMUnpackFunc_T nmLookupFlatUnpacker(NMFType_T eFType)
Lookup Flat unpacker function, given the message field type.
NMFieldThis_T m_this
specific field information
Definition: netmsgs.h:385
NMFType_T
Definition: netmsgs.h:110
NMFieldDef_P m_pThisElem
vector element specific info
Definition: netmsgs.h:356
size_t m_uElemSize
vector element storage size
Definition: netmsgs.h:355
#define NMLIB_RAISE_FIELD_ERROR(ecode, p, fmt,...)
Raise libnetmsgs field error (i.e. return from calling function).
#define NMLIB_ASCII_FTYPE(ftype)
Printable ASCII Field Type.
byte_t * m_buf
the vector
Definition: netmsgs.h:397

Variable Documentation

NMLookupTblEntry_T NMFlatLookupTbl[]
static
Initial value:
=
{
{NMFTypeChar, nmPackFlatU8, nmUnpackFlatU8},
}
static int nmUnpackFlatString(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack variable length string Flat field from the message buffer.
64-bit IEEE 754 FPN double
Definition: netmsgs.h:120
unsigned 8-bit integer unsigned char
Definition: netmsgs.h:118
static int nmUnpackFlatF32(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack a 32-bit floating-point number Flat field from the message buffer.
static int nmUnpackFlatPad(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack pad byte from the message buffer.
32-bit IEEE 754 FPN float
Definition: netmsgs.h:134
static int nmPackFlatS8(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a signed 8-bit Flat field into the message buffer.
unsigned 64-bit integer unsigned long long
Definition: netmsgs.h:128
structure struct T
Definition: netmsgs.h:146
static int nmUnpackFlatStruct(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack structure Flat field from the message buffer.
static int nmPackFlatPad(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack pad bytes into the message buffer.
Definition: nmLibPackFlat.c:89
static int nmPackFlatS16(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a signed 16-bit Flat field into the message buffer.
static int nmPackFlatF32(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a 32-bit floating-point number Flat field into the message buffer.
signed 32-bit integer int
Definition: netmsgs.h:138
static int nmUnpackFlatS16(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack a signed 16-bit Flat field from the message buffer.
string char[]
Definition: netmsgs.h:144
static int nmPackFlatString(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack null-terminated, fixed length string Flat field into the message buffer.
static int nmUnpackFlatP64(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack a 64-bit pointer Flat field from the message buffer.
static int nmUnpackFlatBool(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack an unsigned 8-bit boolean Flat field from the message buffer.
static int nmPackFlatStruct(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a structure Flat field into the message buffer.
static int nmPackFlatU8(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack an unsigned 8-bit Flat field into the message buffer.
static int nmUnpackFlatU64(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack an unsigned 64-bit Flat field from the message buffer.
8-bit ASCII characters char
Definition: netmsgs.h:133
signed 64-bit integer long long
Definition: netmsgs.h:142
static int nmUnpackFlatU8(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack an unsigned 8-bit Flat field from the message buffer.
8-bit bool 0/1 bool_t
Definition: netmsgs.h:117
32-bit pointer (overloaded) void*
Definition: netmsgs.h:140
static int nmUnpackFlatP32(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack a 32-bit pointer Flat field from the message buffer.
static int nmUnpackFlatU16(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack an unsigned 16-bit Flat field from the message buffer.
64-bit pointer (overloaded) void*
Definition: netmsgs.h:126
static int nmPackFlatU16(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack an unsigned 16-bit Flat field into the message buffer.
static int nmUnpackFlatU32(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack an unsigned 32-bit Flat field from the message buffer.
static int nmPackFlatF64(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a 64-bit floating-point number Flat field into the message buffer.
static int nmUnpackFlatS64(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack a signed 64-bit Flat field from the message buffer.
static int nmPackFlatP64(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a 64-bit pointer Flat field into the message buffer.
signed 8-bit integer signed char
Definition: netmsgs.h:131
one dimensional array VType[]
Definition: netmsgs.h:130
static int nmPackFlatU32(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack an unsigned 32-bit Flat field into the message buffer.
static int nmUnpackFlatS32(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack a signed 32-bit Flat field from the message buffer.
static int nmPackFlatP32(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a 32-bit pointer Flat field into the message buffer.
static int nmUnpackFlatS8(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack a signed 8-bit Flat field from the message buffer.
unsigned 32-bit integer unsigned int
Definition: netmsgs.h:124
pad internal field type
Definition: netmsgs.h:145
static int nmPackFlatU64(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack an unsigned 64-bit Flat field into the message buffer.
static int nmUnpackFlatVector(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack variable length vector Flat field from the message buffer.
static int nmPackFlatVector(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack variable length vector Flat field into the message buffer.
static int nmPackFlatS32(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a signed 32-bit Flat field into the message buffer.
static int nmPackFlatS64(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a signed 64-bit Flat field into the message buffer.
static int nmUnpackFlatF64(const NMFieldDef_T *pFieldDef, byte_t buf[], size_t bufSize, void *pVal, NMEndian_T eEndian, NMCtl_T *pCtl)
Unpack a 64-bit floating-point number Flat field from the message buffer.
static int nmPackFlatBool(const NMFieldDef_T *pFieldDef, void *pVal, byte_t buf[], size_t bufSize, NMEndian_T eEndian, NMCtl_T *pCtl)
Pack a boolean into an 8-bit Flat field into the message buffer.
unsigned 16-bit integer unsigned short
Definition: netmsgs.h:122
signed 16-bit integer short
Definition: netmsgs.h:136

Flat Info Lookup Table

Warning
Keep in asending order by ftype.

Definition at line 1308 of file nmLibPackFlat.c.