ltkc_base.h
Go to the documentation of this file.
00001 
00002 /*
00003  ***************************************************************************
00004  *  Copyright 2007,2008 Impinj, Inc.
00005  *
00006  *  Licensed under the Apache License, Version 2.0 (the "License");
00007  *  you may not use this file except in compliance with the License.
00008  *  You may obtain a copy of the License at
00009  *
00010  *      http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  *  Unless required by applicable law or agreed to in writing, software
00013  *  distributed under the License is distributed on an "AS IS" BASIS,
00014  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  *  See the License for the specific language governing permissions and
00016  *  limitations under the License.
00017  *
00018  ***************************************************************************
00019  */
00020 
00021 /*
00022  * Version is four each 8-bit numbers:
00023  * major, minor, maintenance, progress number
00024  */
00025 #define LTKC_VERSION        0x01000005
00026 #define LTKC_VERSION_STR    "1.0.0.5"
00027 
00028 enum LLRP_ResultCode;
00029 struct LLRP_SErrorDetails;
00030 struct LLRP_SVendorDescriptor;
00031 struct LLRP_SNamespaceDescriptor;
00032 struct LLRP_STypeDescriptor;
00033 enum LLRP_EFieldType;
00034 enum LLRP_EFieldFormat;
00035 struct LLRP_SFieldDescriptor;
00036 struct LLRP_SEnumTableEntry;
00037 struct LLRP_STypeRegistry;
00038 struct LLRP_SElement;
00039 struct LLRP_SMessage;
00040 struct LLRP_SParameter;
00041 struct LLRP_SDecoder;
00042 struct LLRP_SDecoderOps;
00043 struct LLRP_SDecoderStream;
00044 struct LLRP_SDecoderStreamOps;
00045 struct LLRP_SEncoder;
00046 struct LLRP_SEncoderOps;
00047 struct LLRP_SEncoderStream;
00048 struct LLRP_SEncoderStreamOps;
00049 
00050 
00051 typedef enum LLRP_ResultCode            LLRP_tResultCode;
00052 typedef struct LLRP_SErrorDetails       LLRP_tSErrorDetails;
00053 typedef struct LLRP_SVendorDescriptor   LLRP_tSVendorDescriptor;
00054 typedef struct LLRP_SNamespaceDescriptor LLRP_tSNamespaceDescriptor;
00055 typedef struct LLRP_STypeDescriptor     LLRP_tSTypeDescriptor;
00056 typedef enum LLRP_EFieldType            LLRP_tEFieldType;
00057 typedef enum LLRP_EFieldFormat          LLRP_tEFieldFormat;
00058 typedef struct LLRP_SFieldDescriptor    LLRP_tSFieldDescriptor;
00059 typedef struct LLRP_SEnumTableEntry     LLRP_tSEnumTableEntry;
00060 typedef struct LLRP_STypeRegistry       LLRP_tSTypeRegistry;
00061 typedef struct LLRP_SElement            LLRP_tSElement;
00062 typedef struct LLRP_SMessage            LLRP_tSMessage;
00063 typedef struct LLRP_SParameter          LLRP_tSParameter;
00064 typedef struct LLRP_SDecoder            LLRP_tSDecoder;
00065 typedef struct LLRP_SDecoderOps         LLRP_tSDecoderOps;
00066 typedef struct LLRP_SDecoderStream      LLRP_tSDecoderStream;
00067 typedef struct LLRP_SDecoderStreamOps   LLRP_tSDecoderStreamOps;
00068 typedef struct LLRP_SEncoder            LLRP_tSEncoder;
00069 typedef struct LLRP_SEncoderOps         LLRP_tSEncoderOps;
00070 typedef struct LLRP_SEncoderStream      LLRP_tSEncoderStream;
00071 typedef struct LLRP_SEncoderStreamOps   LLRP_tSEncoderStreamOps;
00072 
00073 
00074 typedef struct
00075 {
00076     llrp_u16_t                  nValue;
00077     llrp_u8_t *                 pValue;
00078 } llrp_u8v_t;
00079 
00080 extern llrp_u8v_t   LLRP_u8v_construct(llrp_u16_t nValue);
00081 extern void         LLRP_u8v_clear(llrp_u8v_t *pDst);
00082 extern void         LLRP_u8v_set(llrp_u8v_t *pDst, llrp_u8v_t  Value);
00083 extern llrp_u8v_t   LLRP_u8v_copy(llrp_u8v_t Value);
00084 
00085 typedef struct
00086 {
00087     llrp_u16_t                  nValue;
00088     llrp_s8_t *                 pValue;
00089 } llrp_s8v_t;
00090 
00091 extern llrp_s8v_t   LLRP_s8v_construct(llrp_u16_t nValue);
00092 extern void         LLRP_s8v_clear(llrp_s8v_t *pDst);
00093 extern void         LLRP_s8v_set(llrp_s8v_t *pDst, llrp_s8v_t  Value);
00094 extern llrp_s8v_t   LLRP_s8v_copy(llrp_s8v_t Value);
00095 
00096 typedef struct
00097 {
00098     llrp_u16_t                  nValue;
00099     llrp_u16_t *                pValue;
00100 } llrp_u16v_t;
00101 
00102 extern llrp_u16v_t  LLRP_u16v_construct(llrp_u16_t nValue);
00103 extern void         LLRP_u16v_clear(llrp_u16v_t *pDst);
00104 extern void         LLRP_u16v_set(llrp_u16v_t *pDst, llrp_u16v_t  Value);
00105 extern llrp_u16v_t  LLRP_u16v_copy(llrp_u16v_t Value);
00106 
00107 typedef struct
00108 {
00109     llrp_u16_t                  nValue;
00110     llrp_s16_t *                pValue;
00111 } llrp_s16v_t;
00112 
00113 extern llrp_s16v_t  LLRP_s16v_construct(llrp_u16_t nValue);
00114 extern void         LLRP_s16v_clear(llrp_s16v_t *pDst);
00115 extern void         LLRP_s16v_set(llrp_s16v_t *pDst, llrp_s16v_t  Value);
00116 extern llrp_s16v_t  LLRP_s16v_copy(llrp_s16v_t Value);
00117 
00118 typedef struct
00119 {
00120     llrp_u16_t                  nValue;
00121     llrp_u32_t *                pValue;
00122 } llrp_u32v_t;
00123 
00124 extern llrp_u32v_t  LLRP_u32v_construct(llrp_u16_t nValue);
00125 extern void         LLRP_u32v_clear(llrp_u32v_t *pDst);
00126 extern void         LLRP_u32v_set(llrp_u32v_t *pDst, llrp_u32v_t  Value);
00127 extern llrp_u32v_t  LLRP_u32v_copy(llrp_u32v_t Value);
00128 
00129 typedef struct
00130 {
00131     llrp_u16_t                  nValue;
00132     llrp_s32_t *                pValue;
00133 } llrp_s32v_t;
00134 
00135 extern llrp_s32v_t  LLRP_s32v_construct(llrp_u16_t nValue);
00136 extern void         LLRP_s32v_clear(llrp_s32v_t *pDst);
00137 extern void         LLRP_s32v_set(llrp_s32v_t *pDst, llrp_s32v_t  Value);
00138 extern llrp_s32v_t  LLRP_s32v_copy(llrp_s32v_t Value);
00139 
00140 typedef struct
00141 {
00142     llrp_u16_t                  nValue;
00143     llrp_u64_t *                pValue;
00144 } llrp_u64v_t;
00145 
00146 extern llrp_u64v_t  LLRP_u64v_construct(llrp_u16_t nValue);
00147 extern void         LLRP_u64v_clear(llrp_u64v_t *pDst);
00148 extern void         LLRP_u64v_set(llrp_u64v_t *pDst, llrp_u64v_t  Value);
00149 extern llrp_u64v_t  LLRP_u64v_copy(llrp_u64v_t Value);
00150 
00151 typedef struct
00152 {
00153     llrp_u16_t                  nValue;
00154     llrp_s64_t *                pValue;
00155 } llrp_s64v_t;
00156 
00157 extern llrp_s64v_t  LLRP_s64v_construct(llrp_u16_t nValue);
00158 extern void         LLRP_s64v_clear(llrp_s64v_t *pDst);
00159 extern void         LLRP_s64v_set(llrp_s64v_t *pDst, llrp_s64v_t  Value);
00160 extern llrp_s64v_t  LLRP_s64v_copy(llrp_s64v_t Value);
00161 
00162 typedef struct
00163 {
00164     llrp_u16_t                  nBit;
00165     llrp_u8_t *                 pValue;
00166 } llrp_u1v_t;
00167 
00168 extern llrp_u1v_t   LLRP_u1v_construct(llrp_u16_t nBit);
00169 extern void         LLRP_u1v_clear(llrp_u1v_t *pDst);
00170 extern void         LLRP_u1v_set(llrp_u1v_t *pDst, llrp_u1v_t  Value);
00171 extern llrp_u1v_t   LLRP_u1v_copy(llrp_u1v_t Value);
00172 
00173 typedef struct
00174 {
00175     llrp_u16_t                  nValue;
00176     llrp_utf8_t *               pValue;
00177 } llrp_utf8v_t;
00178 
00179 extern llrp_utf8v_t LLRP_utf8v_construct(llrp_u16_t nValue);
00180 extern void         LLRP_utf8v_clear(llrp_utf8v_t *pDst);
00181 extern void         LLRP_utf8v_set(llrp_utf8v_t *pDst, llrp_utf8v_t  Value);
00182 extern llrp_utf8v_t LLRP_utf8v_copy(llrp_utf8v_t Value);
00183 
00184 typedef struct
00185 {
00186     llrp_u16_t                  nValue;
00187     llrp_byte_t *               pValue;
00188 } llrp_bytesToEnd_t;
00189 
00190 extern llrp_bytesToEnd_t LLRP_bytesToEnd_construct(llrp_u16_t nValue);
00191 extern void         LLRP_bytesToEnd_clear(llrp_bytesToEnd_t *pDst);
00192 extern void
00193 LLRP_bytesToEnd_set(llrp_bytesToEnd_t *pDst, llrp_bytesToEnd_t  Value);
00194 extern llrp_bytesToEnd_t LLRP_bytesToEnd_copy(llrp_bytesToEnd_t Value);
00195 
00196 typedef struct
00197 {
00198     llrp_u8_t                   aValue[12u];
00199 } llrp_u96_t;
00200 
00201 enum LLRP_ResultCode
00202 {
00203     LLRP_RC_OK                          = 0,
00204     LLRP_RC_MiscError                   = 100,
00205     LLRP_RC_Botch,
00206     LLRP_RC_SendIOError,
00207     LLRP_RC_RecvIOError,
00208     LLRP_RC_RecvEOF,
00209     LLRP_RC_RecvTimeout,
00210     LLRP_RC_RecvFramingError,
00211     LLRP_RC_BadVersion,
00212     LLRP_RC_MissingResponseType,
00213     LLRP_RC_UnknownMessageType,
00214     LLRP_RC_UnknownParameterType,
00215     LLRP_RC_ExcessiveLength,
00216     LLRP_RC_InvalidLength,
00217     LLRP_RC_FieldUnderrun,
00218     LLRP_RC_ReservedBitsUnderrun,
00219     LLRP_RC_FieldOverrun,
00220     LLRP_RC_ReservedBitsOverrun,
00221     LLRP_RC_UnalignedBitField,
00222     LLRP_RC_UnalignedReservedBits,
00223     LLRP_RC_MessageAllocationFailed,
00224     LLRP_RC_ParameterAllocationFailed,
00225     LLRP_RC_FieldAllocationFailed,
00226     LLRP_RC_ExtraBytes,
00227     LLRP_RC_MissingParameter,
00228     LLRP_RC_UnexpectedParameter,
00229     LLRP_RC_InvalidChoiceMember,
00230     LLRP_RC_EnrollBadTypeNumber,
00231     LLRP_RC_NotAllowedAtExtensionPoint,
00232 };
00233 
00234 struct LLRP_SErrorDetails
00235 {
00236     LLRP_tResultCode            eResultCode;
00237     const LLRP_tSTypeDescriptor *pRefType;
00238     const LLRP_tSFieldDescriptor *pRefField;
00239     const char *                pWhatStr;
00240     int                         OtherDetail;
00241     llrp_u8_t                   tcpErrno;
00242 };
00243 
00244 extern void
00245 LLRP_Error_clear (
00246   LLRP_tSErrorDetails *         pError);
00247 
00248 extern void
00249 LLRP_Error_missingParameter (
00250   LLRP_tSErrorDetails *         pError,
00251   const LLRP_tSTypeDescriptor * pRefType);
00252 
00253 extern void
00254 LLRP_Error_unexpectedParameter (
00255   LLRP_tSErrorDetails *         pError,
00256   const LLRP_tSParameter *      pParameter);
00257 
00258 extern void
00259 LLRP_Error_resultCodeAndWhatStr (
00260   LLRP_tSErrorDetails *         pError,
00261   LLRP_tResultCode              eResultCode,
00262   const char *                  pWhatStr);
00263 
00264 
00265 
00266 
00267 struct LLRP_SVendorDescriptor
00268 {
00269     /* Short name for the vendor, e.g. "Acme" */
00270     char *                      pName;
00271 
00272     /* Vendor PEN of a custom message or parameter */
00273     llrp_u32_t                  VendorID;
00274 };
00275 
00276 struct LLRP_SNamespaceDescriptor
00277 {
00278     /* Short name for the namespace, e.g. "acmeNS" */
00279     char *                      pPrefix;
00280 
00281     /* URI for the namespace, this is the true namespace name */
00282     char *                      pURI;
00283 
00284     /* URI for the XSD (schema) for custom parameters and messages
00285      * defined within the namespace */
00286     char *                      pSchemaLocation;
00287 };
00288 
00289 
00290 /*
00291  *
00292  *  +-----------------------+
00293  *  |                       |
00294  *  |  TypeDescriptor       --------+   ppFieldDescriptorTable
00295  *  |                       |       |
00296  *  +-----------------------+       |
00297  *                                  |
00298  *              +-------------------+
00299  *              V
00300  *  +-----------------------+
00301  *  |                       |           [field number]
00302  *  ~  FieldDescriptor *[]  --------+
00303  *  |                       |       |
00304  *  +-----------------------+       |
00305  *                                  |
00306  *              +-------------------+
00307  *              V
00308  *  +-----------------------+
00309  *  |                       |           Optional pEnumTable
00310  *  |  FieldDescriptor      --------+
00311  *  |                       |       |
00312  *  +-----------------------+       |
00313  *                                  |
00314  *              +-------------------+
00315  *              V
00316  *  +-----------------------+
00317  *  |                       |
00318  *  |  EnumTableEntry[]     |
00319  *  |                       |
00320  *  +-----------------------+
00321  *
00322  */
00323 
00324 
00325 
00326 /*
00327  * STypeDescriptor
00328  *
00329  * Describes a message or parameter type.
00330  */
00331 
00332 struct LLRP_STypeDescriptor
00333 {
00334     /* TRUE for a message type, FALSE for a parameter type */
00335     llrp_bool_t                 bIsMessage;
00336 
00337     /* String name of parameter/message type (e.g. "ROSpec") */
00338     char *                      pName;
00339 
00340     /* NULL=>standard LLRP, !NULL=>Vendor (PEN) of custom
00341      * message or parameter */
00342     const LLRP_tSVendorDescriptor *   pVendorDescriptor;
00343 
00344     /* Namespace of message or parameter, for XML */
00345     const LLRP_tSNamespaceDescriptor *pNamespaceDescriptor;
00346 
00347     /* Type number or, for custom, subtype number */
00348     llrp_u32_t                  TypeNum;
00349 
00350     /* For messages (bIsMessage==TRUE), this is the type descriptor for
00351      * the corresponding response. NULL for a request or notification. */
00352     const LLRP_tSTypeDescriptor *   pResponseType;
00353 
00354     /* Table of pointers to the field descriptors */
00355     const LLRP_tSFieldDescriptor * const * const ppFieldDescriptorTable;
00356 
00357     /* Size of an instance of this element type */
00358     unsigned int                nSizeBytes;
00359 
00360     /* Function to make an instance of the parameter or message */
00361     LLRP_tSElement *
00362     (*pfConstruct)(void);
00363 
00364     /* Destruct instance, dealloc memory */
00365     void
00366     (*pfDestruct) (
00367       LLRP_tSElement *          pElement);
00368 
00369     /* Decoder, sometimes used when we want to decode w/o an instance */
00370     /* Function provided by each specific element type
00371      * to decode fields (simple values). Leaves pDecoderStream
00372      * at first subparameter. */
00373 
00374     void
00375     (*pfDecodeFields) (
00376       LLRP_tSElement *          pElement,
00377       LLRP_tSDecoderStream *    pDecoderStream);
00378 
00379     /* After fields are decoded, the CDecoder itself takes care
00380      * of gathering the subparameters into m_listAllSubParameters.
00381      * Once the end of the enclosing TLV (or message) is reached
00382      * this assimilateSubParameters() function is called to
00383      * create parameter refrences from the primary member variables.
00384      */
00385     void
00386     (*pfAssimilateSubParameters) (
00387       LLRP_tSElement *          pElement,
00388       LLRP_tSErrorDetails *     pError);
00389 
00390     /* Encode fields and subparameters */
00391     void
00392     (*pfEncode) (
00393       const LLRP_tSElement *    pElement,
00394       LLRP_tSEncoderStream *    pEncoderStream);
00395 
00396     /* For extension parameters, ask if they are allowed in
00397      * an enclosing parameter or message */
00398     llrp_bool_t
00399     (*pfIsAllowedIn) (
00400       const LLRP_tSTypeDescriptor *pEnclosingElementType);
00401 };
00402 
00403 enum LLRP_EFieldType {
00404     LLRP_FT_U8,  LLRP_FT_S8,  LLRP_FT_U8V,  LLRP_FT_S8V,
00405     LLRP_FT_U16, LLRP_FT_S16, LLRP_FT_U16V, LLRP_FT_S16V,
00406     LLRP_FT_U32, LLRP_FT_S32, LLRP_FT_U32V, LLRP_FT_S32V,
00407     LLRP_FT_U64, LLRP_FT_S64, LLRP_FT_U64V, LLRP_FT_S64V,
00408 
00409     LLRP_FT_U1,  LLRP_FT_U1V, LLRP_FT_U2,   LLRP_FT_U96,
00410     LLRP_FT_UTF8V,
00411 
00412     LLRP_FT_E1,  LLRP_FT_E2,  LLRP_FT_E8,   LLRP_FT_E16,   LLRP_FT_E32,
00413     LLRP_FT_E8V,
00414 
00415     LLRP_FT_BYTESTOEND,
00416 };
00417 
00418 
00419 enum LLRP_EFieldFormat {
00420     LLRP_FMT_NORMAL,
00421     LLRP_FMT_DEC,
00422     LLRP_FMT_HEX,
00423     LLRP_FMT_UTF8,
00424     LLRP_FMT_DATETIME,
00425 };
00426 
00427 
00428 /*
00429  * SFieldDescriptor
00430  *
00431  * Describes a single field.
00432  */
00433 struct LLRP_SFieldDescriptor
00434 {
00435     /* A code for the field type */
00436     LLRP_tEFieldType            eFieldType;
00437     /* A code for how the field should be formatted */
00438     LLRP_tEFieldType            eFieldFormat;
00439     /* String name of field (e.g. "ROSpecID") */
00440     char *                      pName;
00441     /* NULL or ptr to table base for enumerated fields */
00442     const LLRP_tSEnumTableEntry * pEnumTable;
00443 };
00444 
00445 
00446 extern LLRP_tSFieldDescriptor   LLRP_g_fdMessageHeader_Type;
00447 extern LLRP_tSFieldDescriptor   LLRP_g_fdMessageHeader_Length;
00448 extern LLRP_tSFieldDescriptor   LLRP_g_fdMessageHeader_MessageID;
00449 extern LLRP_tSFieldDescriptor   LLRP_g_fdMessageHeader_VendorPEN;
00450 extern LLRP_tSFieldDescriptor   LLRP_g_fdMessageHeader_Subtype;
00451 extern LLRP_tSFieldDescriptor   LLRP_g_fdParameterHeader_TVType;
00452 extern LLRP_tSFieldDescriptor   LLRP_g_fdParameterHeader_TLVType;
00453 extern LLRP_tSFieldDescriptor   LLRP_g_fdParameterHeader_TLVLength;
00454 extern LLRP_tSFieldDescriptor   LLRP_g_fdParameterHeader_VendorPEN;
00455 extern LLRP_tSFieldDescriptor   LLRP_g_fdParameterHeader_Subtype;
00456 
00457 
00458 /*
00459  * SEnumTableEntry
00460  *
00461  * Simple table of enumerations. Table is terminated
00462  * by an entry with pName==NULL.
00463  */
00464 struct LLRP_SEnumTableEntry
00465 {
00466     /* String name, (e.g. "Immediate") */
00467     char *                      pName;
00468     int                         Value;
00469 };
00470 
00471 /*
00472  * STypeRegistry
00473  *
00474  * A collection of pointers to STypeDescriptors.
00475  * During decode operations types can be looked up
00476  * by code (vendor and typenum) or by name.
00477  */
00478 #define LTKC_MAX_CUSTOM_MESSAGE     100u
00479 #define LTKC_MAX_CUSTOM_PARAMETER   300u
00480 struct LLRP_STypeRegistry
00481 {
00482     /* Standard messages subscripted by type number */
00483     const LLRP_tSTypeDescriptor * apStdMessageTypeDescriptors[1024u];
00484     /* Standard parameters subscripted by type number */
00485     const LLRP_tSTypeDescriptor * apStdParameterTypeDescriptors[1024u];
00486 
00487     /* Custom messages, sequential search */
00488     const LLRP_tSTypeDescriptor *
00489                 apCustMessageTypeDescriptors[LTKC_MAX_CUSTOM_MESSAGE];
00490     unsigned int                nCustMessageTypeDescriptors;
00491     /* Custom parameters, sequential search */
00492     const LLRP_tSTypeDescriptor *
00493                 apCustParameterTypeDescriptors[LTKC_MAX_CUSTOM_PARAMETER];
00494     unsigned int                nCustParameterTypeDescriptors;
00495 };
00496 
00497 /* Create a new TypeRegistry */
00498 extern LLRP_tSTypeRegistry *
00499 LLRP_TypeRegistry_construct (void);
00500 
00501 /* Destruct a TypeRegistry */
00502 extern void
00503 LLRP_TypeRegistry_destruct (
00504   LLRP_tSTypeRegistry *         pTypeRegistry);
00505 
00506 /* Add a type descriptor to the registry */
00507 extern LLRP_tResultCode
00508 LLRP_TypeRegistry_enroll (
00509   LLRP_tSTypeRegistry *         pTypeRegistry,
00510   const LLRP_tSTypeDescriptor * pTypeDescriptor);
00511 
00512 /* Lookup a standard message type descriptor. NULL=>not found */
00513 const LLRP_tSTypeDescriptor *
00514 LLRP_TypeRegistry_lookupMessage (
00515   const LLRP_tSTypeRegistry *   pTypeRegistry,
00516   unsigned int                  MessageTypeNum);
00517 
00518 /* Lookup a standard parameter type descriptor. NULL=>not found */
00519 const LLRP_tSTypeDescriptor *
00520 LLRP_TypeRegistry_lookupParameter (
00521   const LLRP_tSTypeRegistry *   pTypeRegistry,
00522   unsigned int                  ParameterTypeNum);
00523 
00524 /* Lookup a custom message type descriptor. NULL=>not found */
00525 const LLRP_tSTypeDescriptor *
00526 LLRP_TypeRegistry_lookupCustomMessage (
00527   const LLRP_tSTypeRegistry *   pTypeRegistry,
00528   unsigned int                  VendorID,
00529   unsigned int                  MessageSubTypeNum);
00530 
00531 /* Lookup a custom parameter type descriptor. NULL=>not found */
00532 const LLRP_tSTypeDescriptor *
00533 LLRP_TypeRegistry_lookupCustomParameter (
00534   const LLRP_tSTypeRegistry *   pTypeRegistry,
00535   unsigned int                  VendorID,
00536   unsigned int                  ParameterSubTypeNum);
00537 
00538 
00539 /*
00540  * SElement
00541  *
00542  * This is the base class for all parameter and message types.
00543  *
00544  * During decode, all subparameters found are entered
00545  * on m_listAllSubParameters. Then the element's
00546  * assimilateSubParameters() member function is called
00547  * to iterate through the list and attach the parameters
00548  * to specific fields.
00549  *
00550  * The m_listAllSubParameters is a secondary reference to
00551  * all the subparameters. When the element is destructed
00552  * all parameters referenced by m_listAllSubParameters
00553  * are deleted. The C++ intrinsic destructors take care
00554  * of deleting the list itself.
00555  *
00556  * During destruct the specific fields are not processed.
00557  * The fields that are lists are automatically desctructed.
00558  * So are the fields that are array types (i.e. utf8v) are
00559  * also automatically destructed. The fields that are simple
00560  * pointers are simply ignored.
00561  *
00562  * This works because every parameter referenced by specific
00563  * fields is also referenced by m_listAllSubParameters.
00564  */
00565 
00566 struct LLRP_SElement
00567 {
00568     /* The type descriptor desribing this element */
00569     const LLRP_tSTypeDescriptor * pType;
00570 
00571     /* Element that encloses this one, NULL if this is top-level element */
00572     LLRP_tSElement *            pParent;
00573 
00574     /* List of all sub elements */
00575     LLRP_tSParameter *          listAllSubParameters;
00576 };
00577 
00578 struct LLRP_SMessage
00579 {
00580     LLRP_tSElement              elementHdr;
00581 
00582     llrp_u32_t                  MessageID;
00583 
00584     LLRP_tSMessage *            pQueueNext;
00585 };
00586 
00587 struct LLRP_SParameter
00588 {
00589     LLRP_tSElement              elementHdr;
00590 
00591     /* Next pointer for list of all sub elements */
00592     LLRP_tSParameter *          pNextAllSubParameters;
00593 
00594     /* Next pointer for element headed by specific member */
00595     LLRP_tSParameter *          pNextSubParameter;
00596 };
00597 
00598 
00599 /*
00600  * ltkc_element.c
00601  */
00602 LLRP_tSElement *
00603 LLRP_Element_construct (
00604   const LLRP_tSTypeDescriptor *  pTypeDescriptor);
00605 
00606 extern void
00607 LLRP_Element_destruct (
00608   LLRP_tSElement *              pElement);
00609 
00610 extern void
00611 LLRP_Element_finalDestruct (
00612   LLRP_tSElement *              pElement);
00613 
00614 extern void
00615 LLRP_Element_addSubParameterToAllList (
00616   LLRP_tSElement *              pElement,
00617   LLRP_tSParameter *            pParameter);
00618 
00619 extern void
00620 LLRP_Element_removeSubParameterFromAllList (
00621   LLRP_tSElement *              pElement,
00622   LLRP_tSParameter *            pParameter);
00623 
00624 extern void
00625 LLRP_Element_clearSubParameterAllList (
00626   LLRP_tSElement *              pElement);
00627 
00628 extern void
00629 LLRP_Element_setSubParameterPtr (
00630   LLRP_tSElement *              pElement,
00631   LLRP_tSParameter **           ppPtr,
00632   LLRP_tSParameter *            pValue);
00633 
00634 extern void
00635 LLRP_Element_addToSubParameterList (
00636   LLRP_tSElement *              pElement,
00637   LLRP_tSParameter **           ppListHead,
00638   LLRP_tSParameter *            pValue);
00639 
00640 extern void
00641 LLRP_Element_attachToSubParameterList (
00642   LLRP_tSParameter **           ppListHead,
00643   LLRP_tSParameter *            pValue);
00644 
00645 extern void
00646 LLRP_Element_clearSubParameterList (
00647   LLRP_tSElement *              pElement,
00648   LLRP_tSParameter **           ppListHead);
00649 
00650 extern int
00651 LLRP_Element_walk (
00652   const LLRP_tSElement *        pElement,
00653   int                           (*pFunc)(
00654                                   const LLRP_tSElement *    pElement,
00655                                   void *                    pArg),
00656   void *                        pArg,
00657   int                           iDepth,
00658   int                           nMaxDepth);
00659 
00660 extern void
00661 LLRP_Message_setMessageID (
00662   LLRP_tSMessage *              pMessage,
00663   llrp_u32_t                    MessageID);
00664 
00665 extern llrp_bool_t
00666 LLRP_Parameter_isAllowedIn (
00667   LLRP_tSParameter *            pParameter,
00668   const LLRP_tSTypeDescriptor * pEnclosingTypeDescriptor);
00669 
00670 extern llrp_bool_t
00671 LLRP_Parameter_isAllowedExtension (
00672   LLRP_tSParameter *            pParameter,
00673   const LLRP_tSTypeDescriptor * pEnclosingTypeDescriptor);
00674 
00675 
00676 /*
00677  *
00678  * By way of example, this is how the CDecoder and CDecoderStream
00679  * classes work. This example is for decoding a binary frame.
00680  *
00681  *      +-------------------+               +---------------+
00682  *      |                   |               |               |
00683  *      |   CDecoder        --------------->| CTypeRegistry |
00684  *      |                   |               |               |
00685  *      +--|----------------+               +---------------+
00686  *         |    ^
00687  * pointer |    |
00688  * to next |    |   +-------------------+
00689  * byte    |    |   |                   |           pointer to msg end
00690  *         |    ^----  CDecoderStream   ----------------+
00691  *         |    |   |                   |               |
00692  *         |    |   +-------------------+               |
00693  *         |    |             ^                         |
00694  *         |    |             |                         |
00695  *         |    |   +-------------------+   ptr to      |
00696  *         |    |   |                   |   TLV end     |
00697  *         |    ^----  CDecoderStream   ------------+   |
00698  *         |    |   |                   |           |   |
00699  *         |    |   +-------------------+           |   |
00700  *         |    |             ^                     |   |
00701  *         |    |             |                     |   |
00702  *         |    |   +-------------------+           |   |
00703  *         |    |   |                   |           |   |
00704  *         |    ^----  CDecoderStream   --------+   |   |
00705  *         |        |                   |       |   |   |
00706  *         |        +-------------------+       |   |   |
00707  *         |                                    |   |   |
00708  *         +-------------------+                |   |   |
00709  *                             |                |   |   |
00710  *                             v                v   v   v
00711  *  +---------------------------------------------------------------+
00712  *  |                   Binary Frame Buffer                         |
00713  *  +---------------------------------------------------------------+
00714  *
00715  *                            \_________________/          Nestec TLVs
00716  *        \________________/\___________________________/  Nested TLVs
00717  *    \_________________________________________________/  Message
00718  *
00719  *
00720  * In the case of binary frame the references are to
00721  * bytes within the buffer. Lookups are by type number.
00722  *
00723  * In the case of an XML DOM tree, the references are
00724  * to nodes in the DOM tre. Lookups are by string name.
00725  */
00726 
00727 struct LLRP_SDecoder
00728 {
00729     const LLRP_tSDecoderOps *   pDecoderOps;
00730 
00731     const LLRP_tSTypeRegistry * pRegistry;
00732 
00733     LLRP_tSElement *            pRootElement;
00734 
00735     LLRP_tSErrorDetails         ErrorDetails;
00736 };
00737 
00738 struct LLRP_SDecoderOps
00739 {
00740     void
00741     (*pfDestruct) (
00742       LLRP_tSDecoder *          pDecoder);
00743 
00744     LLRP_tSMessage *
00745     (*pfDecodeMessage) (
00746       LLRP_tSDecoder *          pDecoder);
00747 };
00748 
00749 struct LLRP_SDecoderStream
00750 {
00751     LLRP_tSDecoderStreamOps *   pDecoderStreamOps;
00752 };
00753 
00754 struct LLRP_SDecoderStreamOps
00755 {
00756     /*
00757      * 8-bit types
00758      */
00759 
00760     llrp_u8_t
00761     (*pfGet_u8) (
00762       LLRP_tSDecoderStream *    pDecoderStream,
00763       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00764 
00765     llrp_s8_t
00766     (*pfGet_s8) (
00767       LLRP_tSDecoderStream *    pDecoderStream,
00768       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00769 
00770     llrp_u8v_t
00771     (*pfGet_u8v) (
00772       LLRP_tSDecoderStream *    pDecoderStream,
00773       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00774 
00775     llrp_s8v_t
00776     (*pfGet_s8v) (
00777       LLRP_tSDecoderStream *    pDecoderStream,
00778       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00779 
00780     /*
00781      * 16-bit types
00782      */
00783 
00784     llrp_u16_t
00785     (*pfGet_u16) (
00786       LLRP_tSDecoderStream *    pDecoderStream,
00787       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00788 
00789     llrp_s16_t
00790     (*pfGet_s16) (
00791       LLRP_tSDecoderStream *    pDecoderStream,
00792       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00793 
00794     llrp_u16v_t
00795     (*pfGet_u16v) (
00796       LLRP_tSDecoderStream *    pDecoderStream,
00797       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00798 
00799     llrp_s16v_t
00800     (*pfGet_s16v) (
00801       LLRP_tSDecoderStream *    pDecoderStream,
00802       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00803 
00804     /*
00805      * 32-bit types
00806      */
00807 
00808     llrp_u32_t
00809     (*pfGet_u32) (
00810       LLRP_tSDecoderStream *    pDecoderStream,
00811       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00812 
00813     llrp_s32_t
00814     (*pfGet_s32) (
00815       LLRP_tSDecoderStream *    pDecoderStream,
00816       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00817 
00818     llrp_u32v_t
00819     (*pfGet_u32v) (
00820       LLRP_tSDecoderStream *    pDecoderStream,
00821       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00822 
00823     llrp_s32v_t
00824     (*pfGet_s32v) (
00825       LLRP_tSDecoderStream *    pDecoderStream,
00826       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00827 
00828     /*
00829      * 64-bit types
00830      */
00831 
00832     llrp_u64_t
00833     (*pfGet_u64) (
00834       LLRP_tSDecoderStream *    pDecoderStream,
00835       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00836 
00837     llrp_s64_t
00838     (*pfGet_s64) (
00839       LLRP_tSDecoderStream *    pDecoderStream,
00840       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00841 
00842     llrp_u64v_t
00843     (*pfGet_u64v) (
00844       LLRP_tSDecoderStream *    pDecoderStream,
00845       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00846 
00847     llrp_s64v_t
00848     (*pfGet_s64v) (
00849       LLRP_tSDecoderStream *    pDecoderStream,
00850       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00851 
00852     /*
00853      * Special types
00854      */
00855 
00856     llrp_u1_t
00857     (*pfGet_u1) (
00858       LLRP_tSDecoderStream *    pDecoderStream,
00859       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00860 
00861     llrp_u1v_t
00862     (*pfGet_u1v) (
00863       LLRP_tSDecoderStream *    pDecoderStream,
00864       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00865 
00866     llrp_u2_t
00867     (*pfGet_u2) (
00868       LLRP_tSDecoderStream *    pDecoderStream,
00869       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00870 
00871     llrp_u96_t
00872     (*pfGet_u96) (
00873       LLRP_tSDecoderStream *    pDecoderStream,
00874       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00875 
00876     llrp_utf8v_t
00877     (*pfGet_utf8v) (
00878       LLRP_tSDecoderStream *    pDecoderStream,
00879       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00880 
00881     llrp_bytesToEnd_t
00882     (*pfGet_bytesToEnd) (
00883       LLRP_tSDecoderStream *    pDecoderStream,
00884       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00885 
00886 
00887     /*
00888      * Enumerated types of various sizes
00889      */
00890 
00891     int
00892     (*pfGet_e1) (
00893        LLRP_tSDecoderStream *   pDecoderStream,
00894        const LLRP_tSFieldDescriptor *pFieldDescriptor);
00895 
00896     int
00897     (*pfGet_e2) (
00898        LLRP_tSDecoderStream *   pDecoderStream,
00899        const LLRP_tSFieldDescriptor *pFieldDescriptor);
00900 
00901     int
00902     (*pfGet_e8) (
00903        LLRP_tSDecoderStream *   pDecoderStream,
00904        const LLRP_tSFieldDescriptor *pFieldDescriptor);
00905 
00906     int
00907     (*pfGet_e16) (
00908        LLRP_tSDecoderStream *   pDecoderStream,
00909        const LLRP_tSFieldDescriptor *pFieldDescriptor);
00910 
00911     int
00912     (*pfGet_e32) (
00913        LLRP_tSDecoderStream *   pDecoderStream,
00914        const LLRP_tSFieldDescriptor *pFieldDescriptor);
00915 
00916     llrp_u8v_t
00917     (*pfGet_e8v) (
00918       LLRP_tSDecoderStream *    pDecoderStream,
00919       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00920 
00921     /*
00922      * Reserved means some number of bits
00923      */
00924 
00925     void
00926     (*pfGet_reserved) (
00927        LLRP_tSDecoderStream *   pDecoderStream,
00928        unsigned int             nBits);
00929 };
00930 
00931 
00932 
00933 struct LLRP_SEncoder
00934 {
00935     const LLRP_tSEncoderOps *   pEncoderOps;
00936 
00937     LLRP_tSErrorDetails         ErrorDetails;
00938 };
00939 
00940 struct LLRP_SEncoderOps
00941 {
00942     void
00943     (*pfDestruct) (
00944       LLRP_tSEncoder *          pEncoder);
00945 
00946     void
00947     (*pfEncodeElement) (
00948       LLRP_tSEncoder *          pEncoder,
00949       const LLRP_tSElement *    pElement);
00950 };
00951 
00952 struct LLRP_SEncoderStream
00953 {
00954     LLRP_tSEncoderStreamOps *   pEncoderStreamOps;
00955 };
00956 
00957 struct LLRP_SEncoderStreamOps
00958 {
00959     void
00960     (*pfPutRequiredSubParameter) (
00961       LLRP_tSEncoderStream *    pEncoderStream,
00962       const LLRP_tSParameter *  pParameter,
00963       const LLRP_tSTypeDescriptor *pRefType);
00964 
00965     void
00966     (*pfPutOptionalSubParameter) (
00967       LLRP_tSEncoderStream *    pEncoderStream,
00968       const LLRP_tSParameter *  pParameter,
00969       const LLRP_tSTypeDescriptor *pRefType);
00970 
00971     void
00972     (*pfPutRequiredSubParameterList) (
00973       LLRP_tSEncoderStream *    pEncoderStream,
00974       const LLRP_tSParameter *  pParameterList,
00975       const LLRP_tSTypeDescriptor *pRefType);
00976 
00977     void
00978     (*pfPutOptionalSubParameterList) (
00979       LLRP_tSEncoderStream *    pEncoderStream,
00980       const LLRP_tSParameter *  pParameterList,
00981       const LLRP_tSTypeDescriptor *pRefType);
00982 
00983     /*
00984      * 8-bit types
00985      */
00986 
00987     void
00988     (*pfPut_u8) (
00989       LLRP_tSEncoderStream *    pEncoderStream,
00990       const llrp_u8_t           Value,
00991       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00992 
00993     void
00994     (*pfPut_s8) (
00995       LLRP_tSEncoderStream *    pEncoderStream,
00996       const llrp_s8_t           Value,
00997       const LLRP_tSFieldDescriptor *pFieldDescriptor);
00998 
00999     void
01000     (*pfPut_u8v) (
01001       LLRP_tSEncoderStream *    pEncoderStream,
01002       const llrp_u8v_t          Value,
01003       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01004 
01005     void
01006     (*pfPut_s8v) (
01007       LLRP_tSEncoderStream *    pEncoderStream,
01008       const llrp_s8v_t          Value,
01009       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01010 
01011     /*
01012      * 16-bit types
01013      */
01014 
01015     void
01016     (*pfPut_u16) (
01017       LLRP_tSEncoderStream *    pEncoderStream,
01018       const llrp_u16_t          Value,
01019       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01020 
01021     void
01022     (*pfPut_s16) (
01023       LLRP_tSEncoderStream *    pEncoderStream,
01024       const llrp_s16_t          Value,
01025       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01026 
01027     void
01028     (*pfPut_u16v) (
01029       LLRP_tSEncoderStream *    pEncoderStream,
01030       const llrp_u16v_t         Value,
01031       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01032 
01033     void
01034     (*pfPut_s16v) (
01035       LLRP_tSEncoderStream *    pEncoderStream,
01036       const llrp_s16v_t         Value,
01037       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01038 
01039     /*
01040      * 32-bit types
01041      */
01042 
01043     void
01044     (*pfPut_u32) (
01045       LLRP_tSEncoderStream *    pEncoderStream,
01046       const llrp_u32_t          Value,
01047       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01048 
01049     void
01050     (*pfPut_s32) (
01051       LLRP_tSEncoderStream *    pEncoderStream,
01052       const llrp_s32_t          Value,
01053       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01054 
01055     void
01056     (*pfPut_u32v) (
01057       LLRP_tSEncoderStream *    pEncoderStream,
01058       const llrp_u32v_t         Value,
01059       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01060 
01061     void
01062     (*pfPut_s32v) (
01063       LLRP_tSEncoderStream *    pEncoderStream,
01064       const llrp_s32v_t         Value,
01065       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01066 
01067     /*
01068      * 64-bit types
01069      */
01070 
01071     void
01072     (*pfPut_u64) (
01073       LLRP_tSEncoderStream *    pEncoderStream,
01074       const llrp_u64_t          Value,
01075       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01076 
01077     void
01078     (*pfPut_s64) (
01079       LLRP_tSEncoderStream *    pEncoderStream,
01080       const llrp_s64_t          Value,
01081       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01082 
01083     void
01084     (*pfPut_u64v) (
01085       LLRP_tSEncoderStream *    pEncoderStream,
01086       const llrp_u64v_t         Value,
01087       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01088 
01089     void
01090     (*pfPut_s64v) (
01091       LLRP_tSEncoderStream *    pEncoderStream,
01092       const llrp_s64v_t         Value,
01093       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01094 
01095     /*
01096      * Special types
01097      */
01098 
01099     void
01100     (*pfPut_u1) (
01101       LLRP_tSEncoderStream *    pEncoderStream,
01102       const llrp_u1_t           Value,
01103       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01104 
01105     void
01106     (*pfPut_u1v) (
01107       LLRP_tSEncoderStream *    pEncoderStream,
01108       const llrp_u1v_t          Value,
01109       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01110 
01111     void
01112     (*pfPut_u2) (
01113       LLRP_tSEncoderStream *    pEncoderStream,
01114       const llrp_u2_t           Value,
01115       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01116 
01117     void
01118     (*pfPut_u96) (
01119       LLRP_tSEncoderStream *    pEncoderStream,
01120       const llrp_u96_t          Value,
01121       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01122 
01123     void
01124     (*pfPut_utf8v) (
01125       LLRP_tSEncoderStream *    pEncoderStream,
01126       const llrp_utf8v_t        Value,
01127       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01128 
01129     void
01130     (*pfPut_bytesToEnd) (
01131       LLRP_tSEncoderStream *    pEncoderStream,
01132       const llrp_bytesToEnd_t   Value,
01133       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01134 
01135     /*
01136      * Enumerated types of various sizes
01137      */
01138 
01139     void
01140     (*pfPut_e1) (
01141       LLRP_tSEncoderStream *    pEncoderStream,
01142       const int                 Value,
01143       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01144 
01145     void
01146     (*pfPut_e2) (
01147       LLRP_tSEncoderStream *    pEncoderStream,
01148       const int                 Value,
01149       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01150 
01151     void
01152     (*pfPut_e8) (
01153       LLRP_tSEncoderStream *    pEncoderStream,
01154       const int                 Value,
01155       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01156 
01157     void
01158     (*pfPut_e16) (
01159       LLRP_tSEncoderStream *    pEncoderStream,
01160       const int                 Value,
01161       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01162 
01163     void
01164     (*pfPut_e32) (
01165       LLRP_tSEncoderStream *    pEncoderStream,
01166       const int                 Value,
01167       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01168 
01169     void
01170     (*pfPut_e8v) (
01171       LLRP_tSEncoderStream *    pEncoderStream,
01172       const llrp_u8v_t          Value,
01173       const LLRP_tSFieldDescriptor *pFieldDescriptor);
01174 
01175 
01176     /*
01177      * Reserved means some number of bits
01178      */
01179 
01180     void
01181     (*pfPut_reserved) (
01182       LLRP_tSEncoderStream *    pEncoderStream,
01183       unsigned int              nBits);
01184 };
01185 
01186 /*
01187  * ltkc_encdec.c
01188  */
01189 extern void
01190 LLRP_Decoder_destruct (
01191   LLRP_tSDecoder *              pDecoder);
01192 
01193 LLRP_tSMessage *
01194 LLRP_Decoder_decodeMessage (
01195   LLRP_tSDecoder *              pDecoder);
01196 
01197 extern void
01198 LLRP_Encoder_destruct (
01199   LLRP_tSEncoder *              pEncoder);
01200 
01201 extern void
01202 LLRP_Encoder_encodeElement (
01203   LLRP_tSEncoder *              pEncoder,
01204   const LLRP_tSElement *        pElement);
01205 
01206 
01207 /*
01208  * ltkc_xmltextencode.c
01209  */
01210 
01211 extern LLRP_tResultCode
01212 LLRP_toXMLString (
01213   const LLRP_tSElement *        pElement,
01214   char *                        pBuffer,
01215   int                           nBuffer);


thingmagic_rfid
Author(s): Brian Bingham
autogenerated on Thu May 16 2019 03:01:23