1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 19 #ifndef OSCL_SOCKET_REQUEST_H_INCLUDED 20 #define OSCL_SOCKET_REQUEST_H_INCLUDED 21 22 #include "oscl_socket_types.h" 23 #include "oscl_vector.h" 24 #include "oscl_mem.h" 25 26 //Internal use buffer types. 27 class PVSockBufSend 28 { 29 public: PVSockBufSend()30 PVSockBufSend(): 31 iPtr(NULL), 32 iLen(0) 33 {} PVSockBufSend(const uint8 * aPtr,uint32 aLen)34 PVSockBufSend(const uint8* aPtr, uint32 aLen): 35 iPtr(aPtr), 36 iLen(aLen) 37 {} PVSockBufSend(const PVSockBufSend & a)38 PVSockBufSend(const PVSockBufSend& a): 39 iPtr(a.iPtr), 40 iLen(a.iLen) 41 {} 42 const uint8* iPtr; 43 uint32 iLen; 44 }; 45 class PVSockBufRecv 46 { 47 public: PVSockBufRecv()48 PVSockBufRecv(): 49 iPtr(NULL), 50 iLen(0), 51 iMaxLen(0) 52 {} PVSockBufRecv(uint8 * aPtr,uint32 aLen,uint32 aMax)53 PVSockBufRecv(uint8* aPtr, uint32 aLen, uint32 aMax): 54 iPtr(aPtr), 55 iLen(aLen), 56 iMaxLen(aMax) 57 {} PVSockBufRecv(const PVSockBufRecv & a)58 PVSockBufRecv(const PVSockBufRecv& a) 59 : iPtr(a.iPtr) 60 , iLen(a.iLen) 61 , iMaxLen(a.iMaxLen) 62 {} 63 uint8* iPtr; 64 uint32 iLen; 65 uint32 iMaxLen; 66 }; 67 68 class OsclSocketI; 69 class OsclSocketRequestAO; 70 71 /**Base class for all socket method parameter sets 72 */ 73 class SocketRequestParam 74 { 75 public: SocketRequestParam(TPVSocketFxn aFxn)76 SocketRequestParam(TPVSocketFxn aFxn) 77 : iFxn(aFxn) 78 {} 79 80 TPVSocketFxn iFxn; 81 }; 82 83 /**Socket method parameter sets 84 */ 85 86 class SendParam: public SocketRequestParam 87 { 88 public: SendParam(const uint8 * & aPtr,uint32 aLen,uint32 aFlags)89 SendParam(const uint8* &aPtr, uint32 aLen, uint32 aFlags) 90 : SocketRequestParam(EPVSocketSend) 91 , iBufSend(aPtr, aLen) 92 , iFlags(aFlags) 93 , iXferLen(0) 94 {} 95 PVSockBufSend iBufSend; 96 uint32 iFlags; 97 uint32 iXferLen; 98 } ; 99 100 class SendToParam: public SocketRequestParam 101 { 102 public: SendToParam(const uint8 * & aPtr,uint32 aLen,OsclNetworkAddress & anAddr,uint32 flags)103 SendToParam(const uint8* &aPtr, uint32 aLen, OsclNetworkAddress& anAddr, uint32 flags) 104 : SocketRequestParam(EPVSocketSendTo) 105 , iBufSend(aPtr, aLen) 106 , iFlags(flags) 107 , iAddr(anAddr) 108 , iXferLen(0) 109 {} ~SendToParam()110 ~SendToParam() 111 {} 112 PVSockBufSend iBufSend; 113 uint32 iFlags; 114 OsclNetworkAddress iAddr; 115 uint32 iXferLen; 116 } ; 117 118 class RecvParam: public SocketRequestParam 119 { 120 public: RecvParam(uint8 * & aPtr,uint32 aMaxLen,uint32 flags)121 RecvParam(uint8* &aPtr, uint32 aMaxLen, uint32 flags) 122 : SocketRequestParam(EPVSocketRecv) 123 , iBufRecv(aPtr, 0, aMaxLen) 124 , iFlags(flags) 125 {} 126 PVSockBufRecv iBufRecv; 127 uint32 iFlags; 128 } ; 129 130 class RecvFromParam: public SocketRequestParam 131 { 132 public: RecvFromParam(uint8 * & aPtr,uint32 aMaxLen,OsclNetworkAddress & aAddress,uint32 flags,uint32 aMultiMax,Oscl_Vector<uint32,OsclMemAllocator> * aPacketLen,Oscl_Vector<OsclNetworkAddress,OsclMemAllocator> * aPacketSource)133 RecvFromParam(uint8* &aPtr, uint32 aMaxLen, 134 OsclNetworkAddress& aAddress, uint32 flags, uint32 aMultiMax 135 , Oscl_Vector<uint32, OsclMemAllocator>*aPacketLen 136 , Oscl_Vector<OsclNetworkAddress, OsclMemAllocator>* aPacketSource) 137 : SocketRequestParam(EPVSocketRecvFrom) 138 , iBufRecv(aPtr, 0, aMaxLen) 139 , iFlags(flags) 140 , iAddr(aAddress) 141 , iMultiMaxLen(aMultiMax) 142 , iPacketLen(aPacketLen) 143 , iPacketSource(aPacketSource) 144 {} 145 PVSockBufRecv iBufRecv; 146 uint32 iFlags; 147 OsclNetworkAddress& iAddr; 148 uint32 iMultiMaxLen; 149 Oscl_Vector<uint32, OsclMemAllocator>* iPacketLen; 150 Oscl_Vector<OsclNetworkAddress, OsclMemAllocator>* iPacketSource; 151 }; 152 153 class BindParam: public SocketRequestParam 154 { 155 public: BindParam(OsclNetworkAddress & anAddr)156 BindParam(OsclNetworkAddress& anAddr) 157 : SocketRequestParam(EPVSocketBind) 158 , iAddr(anAddr) 159 {} 160 OsclNetworkAddress iAddr; 161 } ; 162 163 class ListenParam: public SocketRequestParam 164 { 165 public: ListenParam(uint32 aSize)166 ListenParam(uint32 aSize) 167 : SocketRequestParam(EPVSocketListen) 168 , iQSize(aSize) 169 {} 170 uint32 iQSize; 171 } ; 172 173 class ConnectParam: public SocketRequestParam 174 { 175 public: ConnectParam(OsclNetworkAddress & anAddr)176 ConnectParam(OsclNetworkAddress& anAddr) 177 : SocketRequestParam(EPVSocketConnect) 178 , iAddr(anAddr) 179 {} 180 OsclNetworkAddress iAddr; 181 } ; 182 183 class AcceptParam: public SocketRequestParam 184 { 185 public: AcceptParam(OsclSocketI & aBlankSocket)186 AcceptParam(OsclSocketI& aBlankSocket) 187 : SocketRequestParam(EPVSocketAccept) 188 , iBlankSocket(&aBlankSocket) 189 {} 190 OsclSocketI *iBlankSocket; 191 } ; 192 193 class ShutdownParam: public SocketRequestParam 194 { 195 public: ShutdownParam(TPVSocketShutdown aHow)196 ShutdownParam(TPVSocketShutdown aHow) 197 : SocketRequestParam(EPVSocketShutdown) 198 , iHow(aHow) 199 {} 200 TPVSocketShutdown iHow; 201 } ; 202 203 #include "oscl_socket_tuneables.h" 204 #if PV_SOCKET_SERVER 205 206 class OsclSocketServRequestQElem; 207 208 /** This class defines the request interface to the PV socket 209 server. 210 */ 211 class OsclSocketRequest 212 { 213 public: OsclSocketRequest()214 OsclSocketRequest() 215 : iSocketRequestAO(NULL) 216 , iParam(NULL) 217 , iSocketI(NULL) 218 {} 219 Fxn()220 TPVSocketFxn Fxn() 221 { 222 return iParam->iFxn; 223 } 224 225 OsclSocketRequestAO *iSocketRequestAO; 226 SocketRequestParam *iParam; 227 OsclSocketI * iSocketI; 228 229 void CancelRequest(); 230 void Activate(SocketRequestParam *iParam, OsclSocketRequestAO &a); 231 232 void Complete(OsclSocketServRequestQElem*, int32 aStatus, int32 aSockErr = 0); 233 234 }; 235 236 #endif 237 238 239 #endif 240 241