/******************************************************************************* ** ** Cabletron Systems Incorporated ** Post Office Box 5005 ** Rochester, NH 03866-5005 ** (c) Copyright Cabletron Systems Inc. 1999 ** ** Workfile: %M% ** Logfile: %P% ** Original Author: Todd Crowley ** SCCS Delta ID: %I% ** Last Delta Date/Time: %G% %U% ** *******************************************************************************/ #ifndef LFAPMSG_H_ #define LFAPMSG_H_ #include "Lfap.h" #ifdef __cplusplus extern "C" { #endif /* size of the LFAPIE and lfapui32_t */ #define LFAP_IE_SIZE sizeof(LFAPIE) #define LFAP_UINT32_SIZE sizeof(lfapui32_t) /* encode flag values */ #define LFAP_NOT_ENCODED 0 #define LFAP_ENCODE_IE 1 #define LFAP_ENCODE_FIXED 2 #define LFAP_ENCODE_RECORD 4 #define LFAP_ENCODE_COMPLETE 8 #define LFAP_RESET_FLAGS 1 #define LFAP_NO_RESET_FLAGS 0 /* indicates an empty buffer */ #define LFAP_EMPTY_BUFFER -1 typedef struct lfap_msg_struct { LFAPBuffer buf; LFAPHeader hdr; } LFAPMsg; void freeLfapMsg (void* msg); lfapui16_t getNextLfapMsgId (void); void setLfapMsgId (void* msg, lfapui16_t msgid); void setLfapMsgStatus (void* msg, lfapui8_t status); /* * Macros for retrieving items from a received message buffer. The * buffer should be at least LFAP_HEADER_SIZE in length */ /* macro for retrieving the version from a received message buffer */ #define lfap_msg_get_version(buf) (*((lfapui8_t*)(buf))) /* macro for retrieving the opcode from a received message buffer */ #define lfap_msg_get_opcode(buf) (*(((lfapui8_t*)buf)+1)) /* macro for retrieving the status from a received message buffer */ #define lfap_msg_get_status(buf) (*(((lfapui8_t*)buf)+3)) /* macro for retrieving the message id from a received message buffer */ #define lfap_msg_get_msgid(buf) ntohs(*(((lfapui16_t*)buf)+2)) /* macro for retrieving the message length from a received message buffer */ #define lfap_msg_get_msglen(buf) ntohs(*(((lfapui16_t*)buf)+3)) /* * Macros for retrieving items from a LfapMsg structure. */ /* macro returns the version of the LfapMsg msg */ #define getLfapMsgVersion(msg) ((lfapui8_t) (*(((LFAPMsg*)msg)->buf.buf))) /* macro returns the opcode of the LfapMsg msg */ #define getLfapMsgOpcode(msg) ((lfapui8_t) (((LFAPMsg*)msg)->hdr.opcode)) /* macro returns the status of the LfapMsg msg */ #define getLfapMsgStatus(msg) ((lfapui8_t) (((LFAPMsg*)msg)->hdr.status)) /* macro returns the msgid of the LfapMsg msg */ #define getLfapMsgId(msg) ((lfapui16_t) (((LFAPMsg*)msg)->hdr.msgid)) /* macro returns the last error of the LfapMsg msg */ #define getLfapMsgError(msg) ((int) (((LFAPMsg*)msg)->buf.err)) /* macro returns the length of the internal buffer inside of the LfapMsg msg */ #define getLfapMsgLength(msg) ((int) (((LFAPMsg*)msg)->buf.msglen)) /* macro returns a pointer to the internal buffer inside of the LfapMsg msg */ #define getLfapMsgBuffer(msg) (((LFAPMsg*)msg)->buf.buf) /* macro returns the number of protocol layers from the protocol LFAPIE */ #define getNumberLfapProtocolLayers(protocol) ((protocol)->str.buf[0])/4 #ifdef __cplusplus } #endif #endif /* LFAPMSG_H_ */