You are here: SwitchKit® Development Environment Programmer’s Guide > 7 Message Functions > Message Macros for C Programmers
Message Macros for C Programmers
Description
The following macros are provided to assist in setting up the message. Some macros have a threadsafe version which is indicated by the skts prefix. Macros do not have return values; they evaluate. The listed parameters are to show expected types.
This macro initializes the structure by zeroing the sequence number and size, and by setting the tag. This macro must be called on every message structure.
void sk_initMsg(MsgStruct *m, int tag);
void skts_initMsg(MsgStruct *m, int tag);
If the application should fail to call sk_initMsg() before sending the message, the following text will appear on the console and in the application's maintenance log:
"**Error:Aug 12 2003 09:30:30: Received message with unknown engine type205 - is the sender of this message incorrectly using a pre-3.0 version of SwitchKit? This version of SwitchKit will not work with any pre-3.0versions."
This message incorrectly identifies the source of the problem but indicates that the message was not properly initialized.
This macro sets the size of the message. In general, this macro should not be called. For all fixed-size messages, and almost all variably-sized messages, SwitchKit computes the size of the message automatically. If you don't set the size, and SwitchKit cannot compute it, you get this error code returned: SK_NO_MSG_SIZE. In this case, the size should be set to the length field that would appear in the EXS message, as described by the API Reference. (Note that the actual value set in the MsgStruct.Size field will not necessarily be this exact value.)
void sk_setMsgSize(MsgStruct *m, aBufSize);
XBYTE skts_setMsgSize(MsgStruct *m);
This macro retrieves the size of the message that was previously set via sk_setMsgSize. This function will not cause SwitchKit to recompute the size of the message and therefore should only be called if you are calling sk_setMsgSize(). See sk_setMsgSize() for more details.
XBYTE sk_getMsgSize(MsgStruct *m);
XBYTE skts_getMsgSize(MsgStruct *m);
This macro sets the range of spans and channels for a ChanRangeMsgStruct message. The macro is equivalent to:
crmsg.StartSpan = startSpan;
crmsg.StartChan = startChan;
crmsg.EndSpan = endSpan;
crmsg.EndChan = endChan;
void sk_setRange (ChanRangeMsgStruct* crMsg, int startSpan, int startChan, int endSpan, int endChan);
void skts_setRange (ChanRangeMsgStruct* crMsg, int startSpan, int startChan, int endSpan, int endChan);
This macro evaluates the following cases:
• SK_TYPE_INBOUND: for messages arriving from the switch.
• SK_TYPE_OUTBOUND: for messages destined for the switch.
• SK_TYPE_TOOLKIT: for SwitchKit-specific messages, for example Add LLCNode.
• SK_TYPE_ADMIN: for SwitchKit administrative messages, for example AssociateChannelGroup.
• SK_TYPE_DUMMY: for SwitchManager-specific messages, for example PPLTool, AllInService.
int sk_getMsgType(MsgStruct *m);
int skts_getMsgType(MsgStruct *m);
This macro evaluates TRUE if m points to an inbound message.
bool isInboundMsg(MsgStruct *m);
This macro evaluates TRUE if m points to an outbound message.
bool isOutboundMsg(MsgStruct *m);
This macro evaluates TRUE if m points to a toolkit message.
Syntax
bool isToolkit(MsgStruct *m);
This macro evaluates to the UBYTE message tag as received by the LLC from the switch.
UBYTE sk_getXLTag(MsgStruct *m);
UBYTE skts_getXLTag(MsgStruct *m);
This macro evaluates to the SK tag and will be offset by 10000 if m points to an acknowledgement.
int sk_getMsgTag(MsgStruct *m);
int skts_getMsgTag(MsgStruct *m);
This macro evaluates to the sequence number for the message m is pointing to.
XBYTE sk_getSegNum(MsgStruct *m);
XBYTE skts_getSegNum(MsgStruct *m);
This macro is a convienience macro that sets the sequence number of m to seqNum.
void sk_setSeqNum(MsgStruct *m, XBYTE seqNum);
void skts_setSeqNum(MsgStruct *m, XBYTE seqNum);
This macro evaluates to TRUE if ack is an inbound message and
ack->Status == 0x10.
bool sk_is_positive_ack(MsgStruct *m);