Lines Matching +full:- +full:encoded

16  * not do anything. If the callback function returns a non-zero value, this will
17 * cause the caller to return with the non-zero status.
35 * @param[in] bytes - valid pointer to a byte stream in little-endian format.
36 * @param[in] numOfBytes - number of bytes belongs to the value. Maximum value
49 uint64_t mask = (uint64_t)1 << (uint8_t)(bitsInVal - 1); in bejGetIntegerValue()
50 return (int64_t)((value ^ mask) - mask); in bejGetIntegerValue()
56 * @param[in] enSegment - a valid pointer to a start of a SFLV bejTuple.
57 * @param[out] offsets - this will hold the local offsets.
63 // [Number of bytes need to represent the sequence number] - uint8_t in bejGetLocalBejSFLVOffsets()
64 // [SequenceNumber] - multi byte in bejGetLocalBejSFLVOffsets()
65 // [Format] - uint8_t in bejGetLocalBejSFLVOffsets()
66 // [Number of bytes need to represent the value length] - uint8_t in bejGetLocalBejSFLVOffsets()
67 // [Value length] - multi byte in bejGetLocalBejSFLVOffsets()
73 // Start of length of the value-length bytes. in bejGetLocalBejSFLVOffsets()
81 offsets->formatOffset = formatOffset; in bejGetLocalBejSFLVOffsets()
82 offsets->valueLenNnintOffset = valueLenNnintOffset; in bejGetLocalBejSFLVOffsets()
83 offsets->valueOffset = valueOffset; in bejGetLocalBejSFLVOffsets()
89 * @param[inout] params - a valid BejHandleTypeFuncParam struct with
90 * params->state.encodedSubStream pointing to the start of the encoded stream
91 * and params->state.encodedStreamOffset pointing to the current bejTuple.
96 // Get offsets of different SFLV fields with respect to start of the encoded in bejInitSFLVStruct()
98 bejGetLocalBejSFLVOffsets(params->state.encodedSubStream, &localOffset); in bejInitSFLVStruct()
99 struct BejSFLV* sflv = &params->sflv; in bejInitSFLVStruct()
101 params->state.encodedSubStream + localOffset.valueLenNnintOffset)); in bejInitSFLVStruct()
104 uint32_t tupleS = (uint32_t)(bejGetNnint(params->state.encodedSubStream)); in bejInitSFLVStruct()
105 sflv->tupleS.schema = (uint8_t)(tupleS & DICTIONARY_TYPE_MASK); in bejInitSFLVStruct()
106 sflv->tupleS.sequenceNumber = in bejInitSFLVStruct()
109 sflv->format = *(struct BejTupleF*)(params->state.encodedSubStream + in bejInitSFLVStruct()
111 sflv->valueLength = valueLength; in bejInitSFLVStruct()
112 sflv->valueEndOffset = params->state.encodedStreamOffset + in bejInitSFLVStruct()
114 sflv->value = params->state.encodedSubStream + localOffset.valueOffset; in bejInitSFLVStruct()
122 * of the encoded stream.
124 * @param[in] params - a valid BejHandleTypeFuncParam struct.
125 * @return offset with respect to the start of the encoded stream.
131 // Get the offset of the value with respect to the current encoded segment in bejGetFirstTupleOffset()
133 bejGetLocalBejSFLVOffsets(params->state.encodedSubStream, &localOffset); in bejGetFirstTupleOffset()
134 return params->state.encodedStreamOffset + localOffset.valueOffset + in bejGetFirstTupleOffset()
135 bejGetNnintSize(params->sflv.value); in bejGetFirstTupleOffset()
141 * @param[in] params - a BejHandleTypeFuncParam struct pointing to valid
143 * @param[in] schemaType - indicate whether to use the annotation dictionary or
145 * @param[in] sequenceNumber - sequence number to use for property search. Not
146 * using the params->sflv.tupleS.sequenceNumber from the provided params struct.
147 * @param[out] dictionary - if the function is successful, this will point to a
149 * @param[out] prop - if the function is successful, this will point to a valid
162 *dictionary = params->mainDictionary; in bejGetDictionaryAndProperty()
163 dictPropOffset = params->state.mainDictPropOffset; in bejGetDictionaryAndProperty()
167 *dictionary = params->annotDictionary; in bejGetDictionaryAndProperty()
168 dictPropOffset = params->state.annoDictPropOffset; in bejGetDictionaryAndProperty()
189 * @brief Find and return the property name of the current encoded segment. If
190 * the params->state.addPropertyName is false, this will return an empty string.
192 * @param[in] params - a valid populated BejHandleTypeFuncParam.
199 if (!params->state.addPropertyName || in bejGetPropName()
200 (bejGetDictionaryAndProperty(params, params->sflv.tupleS.schema, in bejGetPropName()
201 params->sflv.tupleS.sequenceNumber, in bejGetPropName()
206 return bejDictGetPropertyName(dictionary, prop->nameOffset, in bejGetPropName()
207 prop->nameLength); in bejGetPropName()
213 * This figures out whether the current encoded segment marks a section
218 * @param[in] params - a valid BejHandleTypeFuncParam which contains the decoder
220 * @param[in] canBeEmpty - if true, the stack being empty is not an error. If
227 if (params->stackCallback->stackEmpty(params->stackDataPtr) && !canBeEmpty) in bejProcessEnding()
235 while (!params->stackCallback->stackEmpty(params->stackDataPtr)) in bejProcessEnding()
238 params->stackCallback->stackPeek(params->stackDataPtr); in bejProcessEnding()
241 if (params->state.encodedStreamOffset == ending->streamEndOffset) in bejProcessEnding()
246 params->state.mainDictPropOffset = ending->mainDictPropOffset; in bejProcessEnding()
247 params->state.annoDictPropOffset = ending->annoDictPropOffset; in bejProcessEnding()
248 params->state.addPropertyName = ending->addPropertyName; in bejProcessEnding()
250 if (ending->sectionType == bejSectionSet) in bejProcessEnding()
253 params->decodedCallback->callbackSetEnd, in bejProcessEnding()
254 params->callbacksDataPtr); in bejProcessEnding()
256 else if (ending->sectionType == bejSectionArray) in bejProcessEnding()
259 params->decodedCallback->callbackArrayEnd, in bejProcessEnding()
260 params->callbacksDataPtr); in bejProcessEnding()
262 params->stackCallback->stackPop(params->stackDataPtr); in bejProcessEnding()
267 params->decodedCallback->callbackPropertyEnd, in bejProcessEnding()
268 params->callbacksDataPtr); in bejProcessEnding()
278 * @brief Check whether the current encoded segment being decoded is an array
281 * @param[in] params - a valid BejHandleTypeFuncParam struct.
282 * @return true if the encoded segment is an array element. Else false.
286 // If the encoded segment enters an array section, we are adding a in bejIsArrayElement()
287 // BejSectionArray to the stack. Therefore if the stack is empty, encoded in bejIsArrayElement()
289 if (params->stackCallback->stackEmpty(params->stackDataPtr)) in bejIsArrayElement()
294 params->stackCallback->stackPeek(params->stackDataPtr); in bejIsArrayElement()
295 // If the stack top element holds a BejSectionArray, encoded segment is in bejIsArrayElement()
297 return ending->sectionType == bejSectionArray; in bejIsArrayElement()
303 * @param[in] params - a valid BejHandleTypeFuncParam struct.
308 uint16_t sequenceNumber = params->sflv.tupleS.sequenceNumber; in bejHandleBejSet()
318 bejGetDictionaryAndProperty(params, params->sflv.tupleS.schema, in bejHandleBejSet()
322 if (params->state.addPropertyName) in bejHandleBejSet()
324 propName = bejDictGetPropertyName(dictionary, prop->nameOffset, in bejHandleBejSet()
325 prop->nameLength); in bejHandleBejSet()
328 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackSetStart, in bejHandleBejSet()
329 propName, params->callbacksDataPtr); in bejHandleBejSet()
333 params->state.encodedStreamOffset = bejGetFirstTupleOffset(params); in bejHandleBejSet()
335 uint64_t elements = bejGetNnint(params->sflv.value); in bejHandleBejSet()
339 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackSetEnd, in bejHandleBejSet()
340 params->callbacksDataPtr); in bejHandleBejSet()
351 .addPropertyName = params->state.addPropertyName, in bejHandleBejSet()
352 .mainDictPropOffset = params->state.mainDictPropOffset, in bejHandleBejSet()
353 .annoDictPropOffset = params->state.annoDictPropOffset, in bejHandleBejSet()
354 .streamEndOffset = params->sflv.valueEndOffset, in bejHandleBejSet()
357 params->stackCallback->stackPush(&newEnding, params->stackDataPtr)); in bejHandleBejSet()
358 params->state.addPropertyName = true; in bejHandleBejSet()
359 if (params->sflv.tupleS.schema == bejAnnotation) in bejHandleBejSet()
363 params->state.annoDictPropOffset = prop->childPointerOffset; in bejHandleBejSet()
367 params->state.mainDictPropOffset = prop->childPointerOffset; in bejHandleBejSet()
375 * @param[in] params - a valid BejHandleTypeFuncParam struct.
383 params, params->sflv.tupleS.schema, params->sflv.tupleS.sequenceNumber, in bejHandleBejArray()
387 if (params->state.addPropertyName) in bejHandleBejArray()
389 propName = bejDictGetPropertyName(dictionary, prop->nameOffset, in bejHandleBejArray()
390 prop->nameLength); in bejHandleBejArray()
393 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackArrayStart, in bejHandleBejArray()
394 propName, params->callbacksDataPtr); in bejHandleBejArray()
398 params->state.encodedStreamOffset = bejGetFirstTupleOffset(params); in bejHandleBejArray()
400 uint64_t elements = bejGetNnint(params->sflv.value); in bejHandleBejArray()
404 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackArrayEnd, in bejHandleBejArray()
405 params->callbacksDataPtr); in bejHandleBejArray()
416 .addPropertyName = params->state.addPropertyName, in bejHandleBejArray()
417 .mainDictPropOffset = params->state.mainDictPropOffset, in bejHandleBejArray()
418 .annoDictPropOffset = params->state.annoDictPropOffset, in bejHandleBejArray()
419 .streamEndOffset = params->sflv.valueEndOffset, in bejHandleBejArray()
422 params->stackCallback->stackPush(&newEnding, params->stackDataPtr)); in bejHandleBejArray()
424 params->state.addPropertyName = false; in bejHandleBejArray()
425 if (params->sflv.tupleS.schema == bejAnnotation) in bejHandleBejArray()
429 params->state.annoDictPropOffset = prop->childPointerOffset; in bejHandleBejArray()
433 params->state.mainDictPropOffset = prop->childPointerOffset; in bejHandleBejArray()
441 * @param[in] params - a valid BejHandleTypeFuncParam struct.
447 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackNull, propName, in bejHandleBejNull()
448 params->callbacksDataPtr); in bejHandleBejNull()
449 params->state.encodedStreamOffset = params->sflv.valueEndOffset; in bejHandleBejNull()
456 * @param[in] params - a valid BejHandleTypeFuncParam struct.
463 if (params->sflv.valueLength == 0) in bejHandleBejInteger()
465 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackNull, in bejHandleBejInteger()
466 propName, params->callbacksDataPtr); in bejHandleBejInteger()
471 params->decodedCallback->callbackInteger, propName, in bejHandleBejInteger()
472 bejGetIntegerValue(params->sflv.value, params->sflv.valueLength), in bejHandleBejInteger()
473 params->callbacksDataPtr); in bejHandleBejInteger()
475 params->state.encodedStreamOffset = params->sflv.valueEndOffset; in bejHandleBejInteger()
482 * @param[in] params - a valid BejHandleTypeFuncParam struct.
487 uint16_t sequenceNumber = params->sflv.tupleS.sequenceNumber; in bejHandleBejEnum()
495 bejGetDictionaryAndProperty(params, params->sflv.tupleS.schema, in bejHandleBejEnum()
499 if (params->state.addPropertyName) in bejHandleBejEnum()
501 propName = bejDictGetPropertyName(dictionary, prop->nameOffset, in bejHandleBejEnum()
502 prop->nameLength); in bejHandleBejEnum()
505 if (params->sflv.valueLength == 0) in bejHandleBejEnum()
507 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackNull, in bejHandleBejEnum()
508 propName, params->callbacksDataPtr); in bejHandleBejEnum()
514 (uint16_t)(bejGetNnint(params->sflv.value)); in bejHandleBejEnum()
517 bejDictGetProperty(dictionary, prop->childPointerOffset, in bejHandleBejEnum()
520 dictionary, enumValueProp->nameOffset, enumValueProp->nameLength); in bejHandleBejEnum()
522 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackEnum, in bejHandleBejEnum()
524 params->callbacksDataPtr); in bejHandleBejEnum()
527 params->state.encodedStreamOffset = params->sflv.valueEndOffset; in bejHandleBejEnum()
534 * @param[in] params - a valid BejHandleTypeFuncParam struct.
542 if (params->sflv.valueLength == 0) in bejHandleBejString()
544 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackNull, in bejHandleBejString()
545 propName, params->callbacksDataPtr); in bejHandleBejString()
549 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackString, in bejHandleBejString()
550 propName, (const char*)(params->sflv.value), in bejHandleBejString()
551 params->callbacksDataPtr); in bejHandleBejString()
553 params->state.encodedStreamOffset = params->sflv.valueEndOffset; in bejHandleBejString()
560 * @param[in] params - a valid BejHandleTypeFuncParam struct.
567 if (params->sflv.valueLength == 0) in bejHandleBejReal()
569 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackNull, in bejHandleBejReal()
570 propName, params->callbacksDataPtr); in bejHandleBejReal()
575 // nnint - Length of whole in bejHandleBejReal()
576 // bejInteger - whole (includes sign for the overall real number) in bejHandleBejReal()
577 // nnint - Leading zero count for fract in bejHandleBejReal()
578 // nnint - fract in bejHandleBejReal()
579 // nnint - Length of exp in bejHandleBejReal()
580 // bejInteger - exp (includes sign for the exponent) in bejHandleBejReal()
581 uint8_t wholeByteLen = (uint8_t)bejGetNnint(params->sflv.value); in bejHandleBejReal()
583 params->sflv.value + bejGetNnintSize(params->sflv.value); in bejHandleBejReal()
600 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackReal, in bejHandleBejReal()
602 params->callbacksDataPtr); in bejHandleBejReal()
604 params->state.encodedStreamOffset = params->sflv.valueEndOffset; in bejHandleBejReal()
611 * @param[in] params - a valid BejHandleTypeFuncParam struct.
618 if (params->sflv.valueLength == 0) in bejHandleBejBoolean()
620 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackNull, in bejHandleBejBoolean()
621 propName, params->callbacksDataPtr); in bejHandleBejBoolean()
625 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackBool, in bejHandleBejBoolean()
626 propName, *(params->sflv.value) > 0, in bejHandleBejBoolean()
627 params->callbacksDataPtr); in bejHandleBejBoolean()
629 params->state.encodedStreamOffset = params->sflv.valueEndOffset; in bejHandleBejBoolean()
636 * @param[in] params - a valid BejHandleTypeFuncParam struct.
641 // TODO: Handle colon-delimited string values. in bejHandleBejPropertyAnnotation()
648 params, params->sflv.tupleS.schema, params->sflv.tupleS.sequenceNumber, in bejHandleBejPropertyAnnotation()
652 outerDictionary, outerProp->nameOffset, outerProp->nameLength); in bejHandleBejPropertyAnnotation()
653 RETURN_IF_CALLBACK_IERROR(params->decodedCallback->callbackAnnotation, in bejHandleBejPropertyAnnotation()
654 propName, params->callbacksDataPtr); in bejHandleBejPropertyAnnotation()
659 .addPropertyName = params->state.addPropertyName, in bejHandleBejPropertyAnnotation()
660 .mainDictPropOffset = params->state.mainDictPropOffset, in bejHandleBejPropertyAnnotation()
661 .annoDictPropOffset = params->state.annoDictPropOffset, in bejHandleBejPropertyAnnotation()
662 .streamEndOffset = params->sflv.valueEndOffset, in bejHandleBejPropertyAnnotation()
666 params->stackCallback->stackPush(&newEnding, params->stackDataPtr)); in bejHandleBejPropertyAnnotation()
667 params->state.addPropertyName = true; in bejHandleBejPropertyAnnotation()
669 params->state.mainDictPropOffset = outerProp->childPointerOffset; in bejHandleBejPropertyAnnotation()
671 params->state.encodedStreamOffset = in bejHandleBejPropertyAnnotation()
672 params->sflv.valueEndOffset - params->sflv.valueLength; in bejHandleBejPropertyAnnotation()
677 * @brief Decodes an encoded bej stream.
679 * @param[in] schemaDictionary - main schema dictionary to use.
680 * @param[in] annotationDictionary - annotation dictionary
681 * @param[in] enStream - encoded stream without the PLDM header.
682 * @param[in] streamLen - length of the enStream.
683 * @param[in] stackCallback - callbacks for stack handlers.
684 * @param[in] decodedCallback - callbacks for extracting decoded properties.
685 * @param[in] callbacksDataPtr - data pointer to pass to decoded callbacks. This
687 * @param[in] stackDataPtr - data pointer to pass to stack callbacks. This can
710 // Current location of the encoded segment we are processing. in bejDecode()
724 // Go to the next encoded segment in the encoded stream. in bejDecode()
732 params.decodedCallback->callbackReadonlyProperty, in bejDecode()
792 if (!params.stackCallback->stackEmpty(params.stackDataPtr)) in bejDecode()
804 * @param[in] bejVersion - the bej version in the received encoded stream
827 NULL_CHECK(dictionaries->schemaDictionary, "schemaDictionary"); in bejDecodePldmBlock()
828 NULL_CHECK(dictionaries->annotationDictionary, "annotationDictionary"); in bejDecodePldmBlock()
833 NULL_CHECK(stackCallback->stackEmpty, "stackEmpty"); in bejDecodePldmBlock()
834 NULL_CHECK(stackCallback->stackPeek, "stackPeek"); in bejDecodePldmBlock()
835 NULL_CHECK(stackCallback->stackPop, "stackPop"); in bejDecodePldmBlock()
836 NULL_CHECK(stackCallback->stackPush, "stackPush"); in bejDecodePldmBlock()
850 if (!bejIsSupported(pldmHeader->bejVersion)) in bejDecodePldmBlock()
853 pldmHeader->bejVersion); in bejDecodePldmBlock()
857 if (pldmHeader->schemaClass == bejAnnotationSchemaClass) in bejDecodePldmBlock()
864 if (pldmHeader->schemaClass == bejCollectionMemberTypeSchemaClass) in bejDecodePldmBlock()
871 if (pldmHeader->schemaClass == bejErrorSchemaClass) in bejDecodePldmBlock()
879 uint32_t streamLen = blockLength - pldmHeaderSize; in bejDecodePldmBlock()
880 return bejDecode(dictionaries->schemaDictionary, in bejDecodePldmBlock()
881 dictionaries->annotationDictionary, enStream, streamLen, in bejDecodePldmBlock()