sk_packAutoStorage()

Description

The sk_packAutoStorage() function converts the message into a sequence of bytes suitable for sending to the LLC. This function is equivalent to sk_packMessage(), except that instead of requiring you to pass in a pre-allocated buffer, it automatically allocates an appropriate buffer with sufficient storage for the given message.

Syntax

int sk_packAutoStorage(MsgStruct *aMsgStruct, char **BufferPtr, int *aBufSize);

Parameters

The function parameters are shown in the table below.

Argument

Description

MsgStruct **m

Pointer to a generic C Structure representing a message.

aBufferPtr

Pointer to a packed message pointing to memory allocated and owned by SwitchKit API. Application wishing to retain this information beyond the next call to a SwitchKit API function should copy the data to memory allocated and controlled by the application as the memory may be reused the next time a SwitchKit API function is called.

aBufSize

Size of the packed message.

Return Values

Possible return values for this function:

SK_LOST_LLC

This return value indicates that your application lost contact with the LLC.

SK_UNKNOWN_MSG_TYPE

The tag field of this MsgStruct is invalid. Did you call sk_initMsg()?

SK_BAD_MSG_
SIZE

The size field computed by SwitchKit does not match the size field set through sk_setMsgSize(). For this message, you should not set the message size, and instead should let SwitchKit compute it automatically.

SK_NO_MSG_
SIZE

For this MsgStruct, no size was set in with sk_setMsgSize(), and its size couldn’t be computed.