|
|
 |
 |
|
Detailed Description
The PER utility functions are common routines used by both the PER encode and decode functions.
|
Defines |
|
#define | pd_setp(ctxt_p, bufaddr, bufsiz, aligned) pu_setBuffer(ctxt_p, bufaddr, bufsiz, aligned) |
|
#define | pe_resetp(ctxt_p) rtResetContext(ctxt_p) |
|
#define | pd_resetp(ctxt_p) rtResetContext(ctxt_p) |
Functions |
| int | pu_addSizeConstraint (ASN1CTXT *ctxt_p, Asn1SizeCnst *pSize) |
|
ASN1BOOL | pu_alignCharStr (ASN1CTXT *ctxt_p, ASN1UINT len, ASN1UINT nbits, Asn1SizeCnst *pSize) |
| int | pu_checkSizeConstraint (ASN1CTXT *ctxt_p, int size) |
| ASN1UINT | pu_bitcnt (ASN1UINT value) |
|
Asn1SizeCnst * | pu_checkSize (Asn1SizeCnst *pSizeList, ASN1UINT value, ASN1BOOL *pExtendable) |
| void | pu_freeContext (ASN1CTXT *ctxt_p) |
| int | pu_getBitOffset (ASN1CTXT *ctxt_p) |
|
size_t | pu_getMaskAndIndex (size_t bitOffset, unsigned char *pMask) |
| size_t | pu_getMsgLen (ASN1CTXT *ctxt_p) |
| void | pu_hexdump (ASN1CTXT *ctxt_p) |
|
int | pu_setBuffer (ASN1CTXT *ctxt_p, ASN1OCTET *bufaddr, size_t bufsiz, ASN1BOOL aligned) |
|
int | pe_setp (ASN1CTXT *ctxt_p, ASN1OCTET *bufaddr, size_t bufsiz, ASN1BOOL aligned) |
| int | pu_initContext (ASN1CTXT *ctxt_p, ASN1OCTET *bufaddr, ASN1UINT bufsiz, ASN1BOOL aligned) |
| int | pu_initContextBuffer (ASN1CTXT *pTarget, ASN1CTXT *pSource) |
|
ASN1ConstCharPtr | pu_getFullName (ASN1CTXT *ctxt_p, ASN1ConstCharPtr suffix) |
|
Asn1SizeCnst * | pu_getSizeConstraint (ASN1CTXT *ctxt_p, ASN1BOOL extbit) |
|
void | pu_init16BitCharSet (Asn116BitCharSet *pCharSet, ASN116BITCHAR first, ASN116BITCHAR last, ASN1UINT abits, ASN1UINT ubits) |
| void | pu_insLenField (ASN1CTXT *ctxt_p) |
| ASN1BOOL | pu_isExtendableSize (Asn1SizeCnst *pSizeList) |
| ASN1BOOL | pu_isFixedSize (Asn1SizeCnst *pSizeList) |
| ASN1CTXT * | pu_newContext (ASN1OCTET *bufaddr, ASN1UINT bufsiz, ASN1BOOL aligned) |
|
PERField * | pu_newField (ASN1CTXT *ctxt_p, ASN1ConstCharPtr nameSuffix) |
| void | pu_popName (ASN1CTXT *ctxt_p) |
| void | pu_pushElemName (ASN1CTXT *ctxt_p, int index) |
| void | pu_pushName (ASN1CTXT *ctxt_p, ASN1ConstCharPtr name) |
|
void | pu_setBitOffset (ASN1CTXT *ctxt_p, int bitOffset) |
| void | pu_setCharSet (Asn1CharSet *pCharSet, ASN1ConstCharPtr permSet) |
| void | pu_set16BitCharSet (ASN1CTXT *ctxt_p, Asn116BitCharSet *pCharSet, Asn116BitCharSet *pAlphabet) |
| void | pu_set16BitCharSetFromRange (Asn116BitCharSet *pCharSet, ASN1USINT firstChar, ASN1USINT lastChar) |
| void | pu_setFldBitCount (ASN1CTXT *ctxt_p) |
| void | pu_setFldBitOffset (ASN1CTXT *ctxt_p) |
| ASN1BOOL | pu_setTrace (ASN1CTXT *pCtxt, ASN1BOOL value) |
| void | pu_bindump (ASN1CTXT *ctxt_p, ASN1ConstCharPtr varname) |
|
void | pu_dumpField (ASN1CTXT *ctxt_p, PERField *pField, ASN1ConstCharPtr varname, size_t nextBitOffset, BinDumpBuffer *pbuf) |
|
void | pu_init32BitCharSet (Asn132BitCharSet *pCharSet, ASN132BITCHAR first, ASN132BITCHAR last, ASN1UINT abits, ASN1UINT ubits) |
| void | pu_set32BitCharSet (ASN1CTXT *ctxt_p, Asn132BitCharSet *pCharSet, Asn132BitCharSet *pAlphabet) |
| void | pu_set32BitCharSetFromRange (Asn132BitCharSet *pCharSet, ASN1UINT firstChar, ASN1UINT lastChar) |
Function Documentation
| int pu_addSizeConstraint |
( |
ASN1CTXT * |
ctxt_p, |
|
|
Asn1SizeCnst * |
pSize |
|
) |
|
|
|
|
This function is used to add size to a context variable.
- Parameters:
-
| ctxt_p | A pointer to a context structure. The referenced size constraint is added to this structure for use by a subsequent encode or decode function. |
| pSize | A pointer to the size constraint to add the context variable. |
- Returns:
- Completion status of operation:
- 0 (ASN_OK) = success,
- negative return value is error.
|
| void pu_bindump |
( |
ASN1CTXT * |
ctxt_p, |
|
|
ASN1ConstCharPtr |
varname |
|
) |
|
|
|
|
This function provides a detailed binary dump of the contents of the buffer currently specified in the given context. The list of fields dumped by this function was previously built up within the context using calls pu_newField, pu_pushName, and pu_popName. These calls are built into both compiler-generated and low-level PER encode/decode functions to trace the actual bit encoding of a given construct.
- Parameters:
-
| ctxt_p | A pointer to a context structure. The contents of the encode or decode buffer that was specified in the call to pu_initContext or pu_newContext is dumped. |
| varname | The name of the top-level variable name of the structure being dumped. |
|
| ASN1UINT pu_bitcnt |
( |
ASN1UINT |
value |
) |
|
|
|
|
- Parameters:
-
| value | Value to be encoded. |
|
| int pu_checkSizeConstraint |
( |
ASN1CTXT * |
ctxt_p, |
|
|
int |
size |
|
) |
|
|
|
|
- Parameters:
-
| ctxt_p | A pointer to a context structure. The referenced size constraint is added to this structure for use by a subsequent encode or decode function. |
| size | The size constraint to add the context variable. |
|
| void pu_freeContext |
( |
ASN1CTXT * |
ctxt_p |
) |
|
|
|
|
This function releases all dynamicmemeory associated with a context. This function should be called even if the referenced context variable is not dynamic. The reason is because it frees memory allocated within the context as well as the context structure (it will only try to free the context structure if it detects that it was previously allocated using the pu_newContext function).
- Parameters:
-
| ctxt_p | A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. |
|
| int pu_getBitOffset |
( |
ASN1CTXT * |
ctxt_p |
) |
|
|
|
|
- Parameters:
-
| ctxt_p | A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. |
|
| size_t pu_getMsgLen |
( |
ASN1CTXT * |
ctxt_p |
) |
|
|
|
|
This function will return the number of bits in a encoded message. This function is called after a complier generated encode function is called to get the bit count of the encoded component.
- Parameters:
-
| ctxt_p | A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. |
- Returns:
- Length (in bits) of encoded message content.
|
| void pu_hexdump |
( |
ASN1CTXT * |
ctxt_p |
) |
|
|
|
|
This function provides a standard hesadecimal dump of the contents of the buffer currently specified in the given context.
- Parameters:
-
| ctxt_p | Pointer to a context structure. The contents of the encode or decode buffer that was specified in the call to pu_initContext or pu_newContext is dumped. |
|
| int pu_initContext |
( |
ASN1CTXT * |
ctxt_p, |
|
|
ASN1OCTET * |
bufaddr, |
|
|
ASN1UINT |
bufsiz, |
|
|
ASN1BOOL |
aligned |
|
) |
|
|
|
|
This function is used to initialize a pre-allocated ASN1CTXT structure. This can be an ASN1CTXT variable declared on the stack or a pointer to an ASN1CTXT structure that was previously allocated. This function sets all internal variables within the structure to their initial values.
- Parameters:
-
| ctxt_p | A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. |
| bufaddr | For encoding, this is the address of a buffer to receive the encoded PER message (note: this is optional, if specified to NULL a dynamic buffer will be allocated). For decoding, this is that address of the buffer that contains the PER message to be decoded. |
| bufsiz | For encoding, this is the size of the encoded buffer (note: this is optional, if the bufaddr arguement is specified to NULL, then dynamic encoding is in effect and the buffer size is indefinite). For decoding, this is the length (in octets) of the PER message to be decoded. |
| aligned | A Boolean value specifying whether aligned or unaligned encoding should be performed. |
- Returns:
- Completion status of operation:
- 0 (ASN_OK) = success,
- negative return value is error.
|
| int pu_initContextBuffer |
( |
ASN1CTXT * |
pTarget, |
|
|
ASN1CTXT * |
pSource |
|
) |
|
|
|
|
This function is used to initialize the buffer of an ASN1CTXT structure with buffer data from a second context structure. This function copies the buffer information from the source context buffer to the destination structure. The non-buffer related fields in the context remain untouched.
- Parameters:
-
| pTarget | A pointer to the target context structure. Buffer information within this structure is updated with data from the source context. |
| pSource | A pointer to the source context structure. Buffer information from the source context structure is copied to the target structure. |
- Returns:
- Completion status of operation:
- 0 (ASN_OK) = success,
- negative return value is error.
|
| void pu_insLenField |
( |
ASN1CTXT * |
ctxt_p |
) |
|
|
|
|
- Parameters:
-
| ctxt_p | A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. |
|
| ASN1BOOL pu_isExtendableSize |
( |
Asn1SizeCnst * |
pSizeList |
) |
|
|
|
|
- Parameters:
-
| pSizeList | A pointer to the size of the Linked List. |
|
| ASN1BOOL pu_isFixedSize |
( |
Asn1SizeCnst * |
pSizeList |
) |
|
|
|
|
- Parameters:
-
| pSizeList | A pointer to the size of the Linked List. |
|
| ASN1CTXT* pu_newContext |
( |
ASN1OCTET * |
bufaddr, |
|
|
ASN1UINT |
bufsiz, |
|
|
ASN1BOOL |
aligned |
|
) |
|
|
|
|
This function is similar to the pu_initContext function in that it initializes a context variable. The difference is that this function allocates a new structure and then initializes it. It is equivalent to calling malloc to allocate a context structure and then calling pu_initContext to initialize it.
- Parameters:
-
| bufaddr | For encoding, this is the address of a buffer to receive the encoded PER message (note: this is optional, if specified as NULL a dynamic buffer will be allocated). For decoding, this is that address of the buffer that contains the PER message to be decoded. |
| bufsiz | For encoding, this is the size of the encoded buffer (note: this is optional, if the bufaddr argument is specified to NULL, then dynamic encoding is in effect and the buffer size is indefinite). For decoding, this is the length (in octets) of the PER message to be decoded. |
| aligned | A Boolean value specifying whether aligned or unaligned encoding should be performed. |
- Returns:
- A pointer to ASN1CTXT structure to receive the allocated structure. NULL is returned if any error occurs in allocating or initializing the context.
|
| void pu_popName |
( |
ASN1CTXT * |
ctxt_p |
) |
|
|
|
|
- Parameters:
-
| ctxt_p | A pointer to a context structure. |
|
| void pu_pushElemName |
( |
ASN1CTXT * |
ctxt_p, |
|
|
int |
index |
|
) |
|
|
|
|
Pushs an element on the stack.
- Parameters:
-
| ctxt_p | A pointer to a context structure. |
| index | The location to insert the element. |
|
| void pu_pushName |
( |
ASN1CTXT * |
ctxt_p, |
|
|
ASN1ConstCharPtr |
name |
|
) |
|
|
|
|
- Parameters:
-
| ctxt_p | A pointer to a context structure. |
| name | A pointer to the element to add to the stack. |
|
| void pu_set16BitCharSet |
( |
ASN1CTXT * |
ctxt_p, |
|
|
Asn116BitCharSet * |
pCharSet, |
|
|
Asn116BitCharSet * |
pAlphabet |
|
) |
|
|
|
|
This function sets a permitted alphabet character set for 16-bit character strings. This is the resulting set of character when the character associated with a 16-bit string type is merged with a permitted alphabet constraint.
- Parameters:
-
| ctxt_p | Pointer to a context structure. |
| pCharSet | Pointer to a character set structure describing the character set currently associated with the character string type. The resulting character set structure after being merged with the permSet parameter. |
| pAlphabet | Pointer to a structure describing the 16-bit permitted alphabet. |
|
| void pu_set16BitCharSetFromRange |
( |
Asn116BitCharSet * |
pCharSet, |
|
|
ASN1USINT |
firstChar, |
|
|
ASN1USINT |
lastChar |
|
) |
|
|
|
|
- Parameters:
-
| pCharSet | Pointer to a character set structure describing the character set currently associated with the character string type. The resulting character set structure after being merged with the permSet parameter. |
| firstChar | The first character in the range. |
| lastChar | The last character in the range. |
|
| void pu_set32BitCharSet |
( |
ASN1CTXT * |
ctxt_p, |
|
|
Asn132BitCharSet * |
pCharSet, |
|
|
Asn132BitCharSet * |
pAlphabet |
|
) |
|
|
|
|
This function sets a permitted alphabet character set for 32-bit character strings. This is the resulting set of character when the character associated with a 16-bit string type is merged with a permitted alphabet constraint.
- Parameters:
-
| ctxt_p | Pointer to a context structure. |
| pCharSet | Pointer to a character set structure describing the character set currently associated with the character string type. The resulting character set structure after being merged with the permSet parameter. |
| pAlphabet | Pointer to a structure describing the 32-bit permitted alphabet. |
|
| void pu_set32BitCharSetFromRange |
( |
Asn132BitCharSet * |
pCharSet, |
|
|
ASN1UINT |
firstChar, |
|
|
ASN1UINT |
lastChar |
|
) |
|
|
|
|
- Parameters:
-
| pCharSet | Pointer to a character set structure describing the character set currently associated with the character string type. The resulting character set structure after being merged with the permSet parameter. |
| firstChar | The first character in the range. |
| lastChar | The last character in the range. |
|
| void pu_setCharSet |
( |
Asn1CharSet * |
pCharSet, |
|
|
ASN1ConstCharPtr |
permSet |
|
) |
|
|
|
|
This function sets a permitted alphabet character set. This is the resulting set of characters when the character associated with a standard character string type is merged with a permitted alphabet constraint.
- Parameters:
-
| pCharSet | A pointer to a character set structure describing the character set currently associated with the character string type. The resulting character set structure after being merged with the permSet parameter. |
| permSet | A null-terminated string of permitted characters. |
|
| void pu_setFldBitCount |
( |
ASN1CTXT * |
ctxt_p |
) |
|
|
|
|
- Parameters:
-
| ctxt_p | A pointer to a context structure. |
|
| void pu_setFldBitOffset |
( |
ASN1CTXT * |
ctxt_p |
) |
|
|
|
|
- Parameters:
-
| ctxt_p | A pointer to a context structure. |
|
| ASN1BOOL pu_setTrace |
( |
ASN1CTXT * |
pCtxt, |
|
|
ASN1BOOL |
value |
|
) |
|
|
|
|
- Parameters:
-
| pCtxt | A pointer to a context structure. |
| value | The BOOLEAN value to be encoded. |
|
|
This document may be distributed in any form, electronic
or otherwise, provided that it is distributed in its entirety
and that the copyright and this notice are included.
|
This file was last modified on
1 Oct 2004. ASN1C PER Runtime, ASN1C v5.7x |
|