RTP Audio System  2.0.0
tdmessage.h
Go to the documentation of this file.
00001 /*
00002  *  $Id: tdmessage.h 1259 2011-12-17 13:26:09Z dreibh $
00003  *
00004  * SocketAPI implementation for the sctplib.
00005  * Copyright (C) 1999-2012 by Thomas Dreibholz
00006  *
00007  * Realized in co-operation between
00008  * - Siemens AG
00009  * - University of Essen, Institute of Computer Networking Technology
00010  * - University of Applied Sciences, Muenster
00011  *
00012  * Acknowledgement
00013  * This work was partially funded by the Bundesministerium fuer Bildung und
00014  * Forschung (BMBF) of the Federal Republic of Germany (Foerderkennzeichen 01AK045).
00015  * The authors alone are responsible for the contents.
00016  *
00017  * This program is free software: you can redistribute it and/or modify
00018  * it under the terms of the GNU General Public License as published by
00019  * the Free Software Foundation, either version 3 of the License, or
00020  * (at your option) any later version.
00021 
00022  * This program is distributed in the hope that it will be useful,
00023  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025  * GNU General Public License for more details.
00026  *
00027  * You should have received a copy of the GNU General Public License
00028  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00029  *
00030  * Contact: discussion@sctp.de
00031  *          dreibh@iem.uni-due.de
00032  *          tuexen@fh-muenster.de
00033  *
00034  * Purpose: Socket Message
00035  *
00036  */
00037 
00038 
00039 
00040 #ifndef TDMESSAGE_H
00041 #define TDMESSAGE_H
00042 
00043 
00044 #include "tdsystem.h"
00045 #include "socketaddress.h"
00046 
00047 
00048 #include <sys/uio.h>
00049 #include <sys/types.h>
00050 #include <sys/socket.h>
00051 
00052 
00056 inline static size_t CSpace(const size_t payloadLength);
00057 
00061 inline static size_t CLength(const size_t payloadLength);
00062 
00063 
00067 inline static void* CData(cmsghdr* cmsg);
00068 
00072 inline static cmsghdr* CFirstHeader(msghdr* header);
00073 
00077 inline static cmsghdr* CNextHeader(msghdr* header, const cmsghdr* cmsg);
00078 
00079 
00083 inline static const void* CData(const cmsghdr* cmsg);
00084 
00088 inline static const cmsghdr* CFirstHeader(const msghdr* header);
00089 
00093 inline static const cmsghdr* CNextHeader(const msghdr* header, const cmsghdr* cmsg);
00094 
00095 
00105 template<const size_t size> class SocketMessage
00106 {
00107    // ====== Constructor ====================================================
00108    public:
00112    inline SocketMessage();
00113 
00114 
00115    // ====== Structure manipulation =========================================
00119    inline void clear();
00120 
00127    inline SocketAddress* getAddress() const;
00128 
00135    inline void setAddress(const SocketAddress& address,
00136                           const integer        family = AF_UNSPEC);
00137 
00144    inline void setBuffer(void* buffer, const size_t buffersize);
00145 
00156    inline void* addHeader(const size_t payloadLength,
00157                           const int    level,
00158                           const int    type);
00159 
00165    inline cmsghdr* getFirstHeader();
00166 
00173    inline cmsghdr* getNextHeader(cmsghdr* prev);
00174 
00180    inline int getFlags() const;
00181 
00187    inline void setFlags(const int flags);
00188 
00189    // ====== Message structures =============================================
00193    msghdr Header;
00194 
00198    sockaddr_storage Address;
00199 
00203    struct iovec IOVector;
00204 
00205    private:
00206    cmsghdr* NextMsg;
00207 
00211    public:
00212 #ifdef SOLARIS
00213    char Control[_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + _CMSG_DATA_ALIGN(size)];
00214 #else
00215    char Control[CMSG_SPACE(size)];
00216 #endif
00217 };
00218 
00219 
00220 #include "tdmessage.icc"
00221 
00222 
00223 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines