ed2ktypes.h

Go to the documentation of this file.
00001 /**
00002  *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 #ifndef __ED2KTYPES_H__
00020 #define __ED2KTYPES_H__
00021 
00022 /** @file ed2ktypes.h Types related to ED2K module */
00023 
00024 #include <hn/osdep.h>
00025 #include <hn/hnfwd.h>
00026 #include "ed2kfwd.h"
00027 
00028 enum ED2K_Constants {
00029         /**
00030          * The size of a single chunk. This indicates the maximum length of a
00031          * chunk requested from another client. Smaller chunks may be requested
00032          * if neccesery.
00033          */
00034         ED2K_CHUNKSIZE = 180*1024
00035 };
00036 
00037 //! @name Socket types
00038 //@{
00039 typedef SSocket<ED2K, Socket::Server, Socket::TCP> ED2KServerSocket;
00040 typedef SSocket<ED2K, Socket::Client, Socket::TCP> ED2KClientSocket;
00041 // uncomment when SSocket/Scheduler API supports udp sockets
00042 //typedef SSocket<ED2K, Socket::Server, Socket::UDP> ED2KUDPSocket;
00043 typedef UDPSocket ED2KUDPSocket;
00044 //@}
00045 
00046 //! SecIdentState State values
00047 enum SecIdentState {
00048         SI_SIGNEEDED       = 0x01, //!< Signature is needed
00049         SI_KEYANDSIGNEEDED = 0x02  //!< Public key AND signature is needed
00050 };
00051 
00052 //! Types of IP sent in Signature packet; defined here since it's also used in
00053 //! CreditsDb::verifySignature() method
00054 enum IpTypeValues {
00055         IP_LOCAL  = 10,  //!< Sending party's IP address is included
00056         IP_REMOTE = 20,  //!< Receiving party's IP address is included
00057         IP_NONE   = 30   //!< No ip address is included in signature
00058 };
00059 
00060 typedef uint8_t IpType;
00061 
00062 //! Utility - checks whether an ID is low
00063 inline bool isLowId(const uint32_t &id) { return id < 0x00ffffff; }
00064 //! Utility - checks whether an ID is high
00065 inline bool isHighId(const uint32_t &id) { return id > 0x00ffffff; }
00066 
00067 #define COL_SEND COL_CYAN
00068 #define COL_RECV COL_GREEN
00069 #define COL_COMP COL_BYELLOW
00070 
00071 #endif
00072