/*********************************************************************** * * Copyright (C) 2006 Novell, Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; version 2.1 * of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com. * * Author: Juan Carlos Luciani * ***********************************************************************/ #ifndef _CHANNELPROTO_ #define _CHANNELPROTO_ //===[ Include files ]===================================================== //===[ External data ]===================================================== extern string ReqDataPktHdrTemplate; extern string ReqErrorPktHdrTemplate; //===[ External prototypes ]=============================================== //===[ Manifest constants ]================================================ //===[ Type definitions ]================================================== //===[ Function prototypes ]=============================================== //===[ Global variables ]================================================== //===[ Type definitions ]================================================== // // ChannelProto Class Definition // class ChannelProto { public: // Packet Types enum PacketTypes { ReqDataCarrierPacketType = 1, ReqErrorCarrierPacketType, UnknownPacketType }; // // Build Req Data Packet Header routine // // Parameters: // reqId (input) - // Req id. // // payloadLength (input) - // Length of the payload being carried by the packet. // // pPktHdt (input/output) - // Pointer to buffer that will receive the header. // Note, this buffer needs to be big eneough to // contain the ReqDataPktHdrTemplate string. // // Abstract: Returns Req Data Pkt Hdr for the specified // parameters. // // Returns: 0 if successful. // static int buildReqDataPktHdr(uint32_t reqId, int32_t payloadLength, char *pPktHdr); // // Build Req Error Packet Header routine // // Parameters: // reqId (input) - // Req id. // // payloadLength (input) - // Length of the payload being carried by the packet. // // pPktHdt (input/output) - // Pointer to buffer that will receive the header. // Note, this buffer needs to be big eneough to // contain the ReqErrorPktHdrTemplate string. // // Abstract: Returns Req Error Pkt Hdr for the specified // parameters. // // Returns: 0 if successful. // static int buildReqErrorPktHdr(uint32_t reqId, int32_t payloadLength, char *pPktHdr); // // Get Channel Packet Type routine // // Parameters: // buff (input) - // Reference to buffer containing the packet data. // // Abstract: Returns the type of the specified channel packet. // // Returns: Channel packet type. // static PacketTypes getPktType(char &buff); // // Get Req Id and Payload Length Values routine // // Parameters: // buff (input) - // Reference to buffer containing the packet data. // // hdrLength (input) - // Length of the channel header. // // pReqId (input/output) - // Pointer to variable that will receive the req id. // // pPayloadLength (input/output) - // Pointer to variable that will receive the payload length. // // Abstract: Returns the values of the ReqId and PayloadLength headers // present in the channel packet header. // // Returns: True if successful. // static bool getReqIdAndPayloadLength(char *pBuff, int hdrLength, uint32_t *pReqId, int32_t *pPayloadLength); }; //===[ Function prototypes ]=============================================== #endif // _CHANNELPROTO_ //========================================================================= //=========================================================================