00001
00002
00003 #ifndef OSCL_SOCKET_TYPES_H_INCLUDED
00004 #define OSCL_SOCKET_TYPES_H_INCLUDED
00005
00006 #include "osclconfig_io.h"
00007 #include "oscl_types.h"
00008 #include "oscl_scheduler_types.h"
00009 #include "oscl_namestring.h"
00010 #include "oscl_stdstring.h"
00011
00012 enum TPVSocketFxn
00013 {
00014 EPVSocketSend = 0
00015 , EPVSocketSendTo
00016 , EPVSocketRecv
00017 , EPVSocketRecvFrom
00018 , EPVSocketConnect
00019 , EPVSocketAccept
00020 , EPVSocketShutdown
00021 , EPVSocketBind
00022 , EPVSocketListen
00023 , EPVSocket_Last
00024 } ;
00025
00028 enum TPVSocketEvent
00029 {
00030 EPVSocketSuccess
00031 , EPVSocketPending
00032 , EPVSocketTimeout
00033 , EPVSocketFailure
00034 , EPVSocketCancel
00035 , EPVSocketNotImplemented
00036 } ;
00037
00038 enum TPVSocketShutdown
00039 {
00040 EPVSocketSendShutdown
00041 , EPVSocketRecvShutdown
00042 , EPVSocketBothShutdown
00043 } ;
00044
00045 class OsclSocketTOS
00046 {
00047 public:
00048 enum TPVServicePrecedence
00049 {
00050 EPVRoutine = 0,
00051 EPVPriority = 1,
00052 EPVImmediate = 2,
00053 EPVFlash = 3,
00054 EPVOverrideFlash = 4,
00055 EPVCritic_Ecp = 5,
00056 EPVInetControl = 6,
00057 EPVNetControl = 7
00058 };
00059
00060 enum TPVServicePriority
00061 {
00062 EPVNoTOS = 0x0,
00063 EPVLDelay = (1 << 4),
00064 EPVHiThrpt = (1 << 3),
00065 EPVHiRel = (1 << 2)
00066 };
00067
00068 OsclSocketTOS(): iTOSUnusedBits(2), iTOSPriorityBits(3)
00069 {
00070 ClearTOS();
00071 }
00072
00073 void SetPrecedence(TPVServicePrecedence aPrecedence)
00074 {
00075 iPrecedence = aPrecedence;
00076 }
00077
00078 void SetPriority(bool aMinimizeDelay, bool aMaximizeThroughput, bool MaximizeReliability)
00079 {
00080 iPriority = (aMinimizeDelay ? EPVLDelay : EPVNoTOS) | (aMaximizeThroughput ? EPVHiThrpt : EPVNoTOS) | (MaximizeReliability ? EPVHiRel : EPVNoTOS);
00081 }
00082
00083 void ClearTOS()
00084 {
00085 iPrecedence = OsclSocketTOS::EPVRoutine;
00086 iPriority = OsclSocketTOS::EPVNoTOS;
00087 }
00088
00089 uint8 GetTOS() const
00090 {
00097 return ((iPrecedence << (iTOSPriorityBits + iTOSUnusedBits) & 0xFF) || ((iPriority << iTOSUnusedBits) & 0xFF));
00098 }
00099
00100 private:
00101 uint8 iPrecedence;
00102 uint8 iPriority;
00103 const uint8 iTOSUnusedBits;
00104 const uint8 iTOSPriorityBits;
00105 };
00106
00107 enum TPVSocketOptionName
00108 {
00109
00110 EPVIPMulticastTTL
00111 , EPVIPAddMembership
00112 , EPVIPTOS
00113
00114 , EPVSockReuseAddr
00115 } ;
00116
00117 enum TPVSocketOptionLevel
00118 {
00119 EPVIPProtoIP
00120 , EPVIPProtoTCP
00121 , EPVSocket
00122 } ;
00123 #define PVNETWORKADDRESS_LEN 50
00124
00125 class OsclNetworkAddress
00126 {
00127 public:
00128 OsclNetworkAddress(): port(0)
00129 {
00130 }
00131 OsclNetworkAddress(const char *addr, int p)
00132 {
00133 ipAddr.Set(addr);
00134 port = p;
00135 }
00136
00137
00138 OsclNameString<PVNETWORKADDRESS_LEN> ipAddr;
00139
00140
00141 int port;
00142
00143 bool operator == (const OsclNetworkAddress & rhs) const
00144 {
00145 if (port == rhs.port)
00146 {
00147 if (0 == oscl_strcmp((const char*)ipAddr.Str(), (const char*)rhs.ipAddr.Str()))
00148 return true;
00149 }
00150 return false;
00151 };
00152
00153 } ;
00154
00155 class OsclIpMReq
00156 {
00157 public:
00158 OsclIpMReq(
00159 const char *intrfcAddr
00160 , const char* multcstAddr)
00161 {
00162 interfaceAddr.Set(intrfcAddr);
00163 multicastAddr.Set(multcstAddr);
00164 }
00165 OsclNameString<PVNETWORKADDRESS_LEN> interfaceAddr;
00166 OsclNameString<PVNETWORKADDRESS_LEN> multicastAddr;
00167 };
00168
00173 class OsclSocketObserver
00174 {
00175 public:
00188 OSCL_IMPORT_REF virtual void HandleSocketEvent(int32 aId, TPVSocketFxn aFxn, TPVSocketEvent aEvent, int32 aError) = 0;
00189 virtual ~OsclSocketObserver() {}
00190 };
00191
00192
00193 #endif