1 // Copyright (c) 2012- PPSSPP Project.
2
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
6
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
11
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
14
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18 #include "Core/HLE/HLE.h"
19 #include "Core/HLE/FunctionWrappers.h"
20
21 #include "Core/HLE/sceHttp.h"
22 #include "Common/Net/HTTPClient.h"
23
24 // If http isn't loaded (seems unlikely), most functions should return SCE_KERNEL_ERROR_LIBRARY_NOTFOUND
25
26
27 // Could come in handy someday if we ever implement sceHttp* for real.
28 enum PSPHttpMethod {
29 PSP_HTTP_METHOD_GET,
30 PSP_HTTP_METHOD_POST,
31 PSP_HTTP_METHOD_HEAD
32 };
33
34 // Just a holder for settings like user agent string
35 class HTTPTemplate {
36 char useragent[512];
37 };
38
39 class HTTPConnection {
40
41 };
42
43 class HTTPRequest {
44
45 };
46
47
sceHttpSetResolveRetry(int connectionID,int retryCount)48 int sceHttpSetResolveRetry(int connectionID, int retryCount) {
49 ERROR_LOG(SCENET, "UNIMPL sceHttpSetResolveRetry(%d, %d)", connectionID, retryCount);
50 return 0;
51 }
52
sceHttpInit(int unknown)53 static int sceHttpInit(int unknown) {
54 ERROR_LOG(SCENET, "UNIMPL sceHttpInit(%i)", unknown);
55 return 0;
56 }
57
sceHttpEnd()58 static int sceHttpEnd() {
59 ERROR_LOG(SCENET, "UNIMPL sceHttpEnd()");
60 return 0;
61 }
62
sceHttpInitCache(int size)63 static int sceHttpInitCache(int size) {
64 ERROR_LOG(SCENET, "UNIMPL sceHttpInitCache(%d)", size);
65 return 0;
66 }
67
sceHttpEndCache()68 static int sceHttpEndCache() {
69 ERROR_LOG(SCENET, "UNIMPL sceHttpEndCache()");
70 return 0;
71 }
72
sceHttpEnableCache(int id)73 static int sceHttpEnableCache(int id) {
74 ERROR_LOG(SCENET, "UNIMPL sceHttpEnableCache(%d)", id);
75 return 0;
76 }
77
sceHttpDisableCache(int id)78 static int sceHttpDisableCache(int id) {
79 ERROR_LOG(SCENET, "UNIMPL sceHttpDisableCache(%d)", id);
80 return 0;
81 }
82
sceHttpGetProxy(u32 id,u32 activateFlagPtr,u32 modePtr,u32 proxyHostPtr,u32 len,u32 proxyPort)83 static u32 sceHttpGetProxy(u32 id, u32 activateFlagPtr, u32 modePtr, u32 proxyHostPtr, u32 len, u32 proxyPort) {
84 ERROR_LOG(SCENET, "UNIMPL sceHttpGetProxy(%d, %x, %x, %x, %d, %x)", id, activateFlagPtr, modePtr, proxyHostPtr, len, proxyPort);
85 return 0;
86 }
87
sceHttpGetStatusCode(int requestID,u32 statusCodePtr)88 static int sceHttpGetStatusCode(int requestID, u32 statusCodePtr) {
89 ERROR_LOG(SCENET, "UNIMPL sceHttpGetStatusCode(%d, %x)", requestID, statusCodePtr);
90 return 0;
91 }
92
sceHttpReadData(int requestID,u32 dataPtr,u32 dataSize)93 static int sceHttpReadData(int requestID, u32 dataPtr, u32 dataSize) {
94 ERROR_LOG(SCENET, "UNIMPL sceHttpReadData(%d, %x, %x)", requestID, dataPtr, dataSize);
95 return 0;
96 }
97
sceHttpSendRequest(int requestID,u32 dataPtr,u32 dataSize)98 static int sceHttpSendRequest(int requestID, u32 dataPtr, u32 dataSize) {
99 ERROR_LOG(SCENET, "UNIMPL sceHttpSendRequest(%d, %x, %x)", requestID, dataPtr, dataSize);
100 return 0;
101 }
102
sceHttpDeleteRequest(int requestID)103 static int sceHttpDeleteRequest(int requestID) {
104 ERROR_LOG(SCENET, "UNIMPL sceHttpDeleteRequest(%d)", requestID);
105 return 0;
106 }
107
sceHttpDeleteHeader(int id,const char * name)108 static int sceHttpDeleteHeader(int id, const char *name) {
109 ERROR_LOG(SCENET, "UNIMPL sceHttpDeleteHeader(%d, %s)", id, name);
110 return 0;
111 }
112
sceHttpDeleteConnection(int connectionID)113 static int sceHttpDeleteConnection(int connectionID) {
114 ERROR_LOG(SCENET, "UNIMPL sceHttpDisableCache(%d)", connectionID);
115 return 0;
116 }
117
sceHttpSetConnectTimeOut(int id,u32 timeout)118 static int sceHttpSetConnectTimeOut(int id, u32 timeout) {
119 ERROR_LOG(SCENET, "UNIMPL sceHttpSetConnectTimeout(%d, %d)", id, timeout);
120 return 0;
121 }
122
sceHttpSetSendTimeOut(int id,u32 timeout)123 static int sceHttpSetSendTimeOut(int id, u32 timeout) {
124 ERROR_LOG(SCENET, "UNIMPL sceHttpSetSendTimeout(%d, %d)", id, timeout);
125 return 0;
126 }
127
sceHttpSetProxy(u32 id,u32 activateFlagPtr,u32 mode,u32 newProxyHostPtr,u32 newProxyPort)128 static u32 sceHttpSetProxy(u32 id, u32 activateFlagPtr, u32 mode, u32 newProxyHostPtr, u32 newProxyPort) {
129 ERROR_LOG(SCENET, "UNIMPL sceHttpSetProxy(%d, %x, %x, %x, %d)", id, activateFlagPtr, mode, newProxyHostPtr, newProxyPort);
130 return 0;
131 }
132
sceHttpEnableCookie(int id)133 static int sceHttpEnableCookie(int id) {
134 ERROR_LOG(SCENET, "UNIMPL sceHttpEnableCookie(%d)", id);
135 return 0;
136 }
137
sceHttpEnableKeepAlive(int id)138 static int sceHttpEnableKeepAlive(int id) {
139 ERROR_LOG(SCENET, "UNIMPL sceHttpEnableKeepAlive(%d)", id);
140 return 0;
141 }
142
sceHttpDisableCookie(int id)143 static int sceHttpDisableCookie(int id) {
144 ERROR_LOG(SCENET, "UNIMPL sceHttpDisableCookie(%d)", id);
145 return 0;
146 }
147
sceHttpDisableKeepAlive(int id)148 static int sceHttpDisableKeepAlive(int id) {
149 ERROR_LOG(SCENET, "UNIMPL sceHttpDisableKeepAlive(%d)", id);
150 return 0;
151 }
152
sceHttpsInit(int unknown1,int unknown2,int unknown3,int unknown4)153 static int sceHttpsInit(int unknown1, int unknown2, int unknown3, int unknown4) {
154 ERROR_LOG(SCENET, "UNIMPL sceHttpsInit(%d, %d, %d, %d)", unknown1, unknown2, unknown3, unknown4);
155 return 0;
156 }
157
sceHttpsEnd()158 static int sceHttpsEnd() {
159 ERROR_LOG(SCENET, "UNIMPL sceHttpsEnd()");
160 return 0;
161 }
162
163 // Parameter "method" should be one of PSPHttpMethod's listed entries
sceHttpCreateRequest(int connectionID,int method,const char * path,u64 contentLength)164 static int sceHttpCreateRequest(int connectionID, int method, const char *path, u64 contentLength) {
165 ERROR_LOG(SCENET, "UNIMPL sceHttpCreateRequest(%d, %d, %s, %llx)", connectionID, method, path, contentLength);
166 return 0;
167 }
168
sceHttpCreateConnection(int templateID,const char * hostString,const char * unknown1,u32 port,int unknown2)169 static int sceHttpCreateConnection(int templateID, const char *hostString, const char *unknown1, u32 port, int unknown2) {
170 ERROR_LOG(SCENET, "UNIMPL sceHttpCreateConnection(%d, %s, %s, %d, %d)", templateID, hostString, unknown1, port, unknown2);
171 return 0;
172 }
173
sceHttpGetNetworkErrno(int request,u32 errNumPtr)174 static int sceHttpGetNetworkErrno(int request, u32 errNumPtr) {
175 ERROR_LOG(SCENET, "UNIMPL sceHttpGetNetworkErrno(%d, %x)", request, errNumPtr);
176 return 0;
177 }
178
sceHttpAddExtraHeader(int id,const char * name,const char * value,int unknown)179 static int sceHttpAddExtraHeader(int id, const char *name, const char *value, int unknown) {
180 ERROR_LOG(SCENET, "UNIMPL sceHttpAddExtraHeader(%d, %s, %s, %d)", id, name, value, unknown);
181 return 0;
182 }
183
sceHttpAbortRequest(int requestID)184 static int sceHttpAbortRequest(int requestID) {
185 ERROR_LOG(SCENET, "UNIMPL sceHttpAbortRequest(%d)", requestID);
186 return 0;
187 }
188
sceHttpDeleteTemplate(int templateID)189 static int sceHttpDeleteTemplate(int templateID) {
190 ERROR_LOG(SCENET, "UNIMPL sceHttpDeleteTemplate(%d)", templateID);
191 return 0;
192 }
193
sceHttpSetMallocFunction(u32 mallocFuncPtr,u32 freeFuncPtr,u32 reallocFuncPtr)194 static int sceHttpSetMallocFunction(u32 mallocFuncPtr, u32 freeFuncPtr, u32 reallocFuncPtr) {
195 ERROR_LOG(SCENET, "UNIMPL sceHttpSetMallocFunction(%x, %x, %x)", mallocFuncPtr, freeFuncPtr, reallocFuncPtr);
196 return 0;
197 }
198
sceHttpSetResolveTimeOut(int id,u32 timeout)199 static int sceHttpSetResolveTimeOut(int id, u32 timeout) {
200 ERROR_LOG(SCENET, "UNIMPL sceHttpSetResolveTimeOut(%d, %d)", id, timeout);
201 return 0;
202 }
203
sceHttpSetAuthInfoCB(int id,u32 callbackFuncPtr)204 static int sceHttpSetAuthInfoCB(int id, u32 callbackFuncPtr) {
205 ERROR_LOG(SCENET, "UNIMPL sceHttpSetAuthInfoCB(%d, %x)", id, callbackFuncPtr);
206 return 0;
207 }
208
sceHttpEnableRedirect(int id)209 static int sceHttpEnableRedirect(int id) {
210 ERROR_LOG(SCENET, "UNIMPL sceHttpEnableRedirect(%d)", id);
211 return 0;
212 }
213
sceHttpEnableAuth(int id)214 static int sceHttpEnableAuth(int id) {
215 ERROR_LOG(SCENET, "UNIMPL sceHttpEnableAuth(%d)", id);
216 return 0;
217 }
218
sceHttpDisableRedirect(int id)219 static int sceHttpDisableRedirect(int id) {
220 ERROR_LOG(SCENET, "UNIMPL sceHttpDisableRedirect(%d)", id);
221 return 0;
222 }
223
sceHttpDisableAuth(int id)224 static int sceHttpDisableAuth(int id) {
225 ERROR_LOG(SCENET, "UNIMPL sceHttpDisableAuth(%d)", id);
226 return 0;
227 }
228
sceHttpSaveSystemCookie()229 static int sceHttpSaveSystemCookie() {
230 ERROR_LOG(SCENET, "UNIMPL sceHttpSaveSystemCookie()");
231 return 0;
232 }
233
sceHttpsLoadDefaultCert(int unknown1,int unknown2)234 static int sceHttpsLoadDefaultCert(int unknown1, int unknown2) {
235 ERROR_LOG(SCENET, "UNIMPL sceHttpLoadDefaultCert(%d, %d)", unknown1, unknown2);
236 return 0;
237 }
238
sceHttpLoadSystemCookie()239 static int sceHttpLoadSystemCookie() {
240 ERROR_LOG(SCENET, "UNIMPL sceHttpLoadSystemCookie()");
241 return 0;
242 }
243
sceHttpCreateTemplate(const char * agent,int unknown1,int unknown2)244 static int sceHttpCreateTemplate(const char *agent, int unknown1, int unknown2) {
245 ERROR_LOG(SCENET, "UNIMPL sceHttpCreateTemplate(%s, %d, %d)", agent, unknown1, unknown2);
246 return 0;
247 }
248
249 // Parameter "method" should be one of PSPHttpMethod's listed entries
sceHttpCreateRequestWithURL(int connectionID,int method,const char * url,u64 contentLength)250 static int sceHttpCreateRequestWithURL(int connectionID, int method, const char *url, u64 contentLength) {
251 ERROR_LOG(SCENET, "UNIMPL sceHttpCreateRequestWithURL(%d, %d, %s, %llx)", connectionID, method, url, contentLength);
252 return 0;
253 }
254
sceHttpCreateConnectionWithURL(int templateID,const char * url,int unknown1)255 static int sceHttpCreateConnectionWithURL(int templateID, const char *url, int unknown1) {
256 ERROR_LOG(SCENET, "UNIMPL sceHttpCreateConnectionWithURL(%d, %s, %d)", templateID, url, unknown1);
257 return 0;
258 }
259
sceHttpSetRecvTimeOut(int id,u32 timeout)260 static int sceHttpSetRecvTimeOut(int id, u32 timeout) {
261 ERROR_LOG(SCENET, "UNIMPL sceHttpSetRecvTimeOut(%d, %x)", id, timeout);
262 return 0;
263 }
264
sceHttpGetAllHeader(int request,u32 headerPtrToPtr,u32 headerSize)265 static int sceHttpGetAllHeader(int request, u32 headerPtrToPtr, u32 headerSize) {
266 ERROR_LOG(SCENET, "UNIMPL sceHttpGetAllHeader(%d, %x, %x)", request, headerPtrToPtr, headerSize);
267 return 0;
268 }
269
sceHttpGetContentLength(int requestID,u64 contentLengthPtr)270 static int sceHttpGetContentLength(int requestID, u64 contentLengthPtr) {
271 ERROR_LOG(SCENET, "UNIMPL sceHttpGetContentLength(%d, %llx)", requestID, contentLengthPtr);
272 return 0;
273 }
274
275 /*
276 * 0x62411801 sceSircsInit
277 0x19155a2f sceSircsEnd
278 0x71eef62d sceSircsSend
279 */
280 const HLEFunction sceHttp[] = {
281 {0XAB1ABE07, &WrapI_I<sceHttpInit>, "sceHttpInit", 'i', "i" },
282 {0XD1C8945E, &WrapI_V<sceHttpEnd>, "sceHttpEnd", 'i', "" },
283 {0XA6800C34, &WrapI_I<sceHttpInitCache>, "sceHttpInitCache", 'i', "i" },
284 {0X78B54C09, &WrapI_V<sceHttpEndCache>, "sceHttpEndCache", 'i', "" },
285 {0X59E6D16F, &WrapI_I<sceHttpEnableCache>, "sceHttpEnableCache", 'i', "i" },
286 {0XCCBD167A, &WrapI_I<sceHttpDisableCache>, "sceHttpDisableCache", 'i', "i" },
287 {0XD70D4847, &WrapU_UUUUUU<sceHttpGetProxy>, "sceHttpGetProxy", 'x', "xxxxxx"},
288 {0X4CC7D78F, &WrapI_IU<sceHttpGetStatusCode>, "sceHttpGetStatusCode", 'i', "ix" },
289 {0XEDEEB999, &WrapI_IUU<sceHttpReadData>, "sceHttpReadData", 'i', "ixx" },
290 {0XBB70706F, &WrapI_IUU<sceHttpSendRequest>, "sceHttpSendRequest", 'i', "ixx" },
291 {0XA5512E01, &WrapI_I<sceHttpDeleteRequest>, "sceHttpDeleteRequest", 'i', "i" },
292 {0X15540184, &WrapI_IC<sceHttpDeleteHeader>, "sceHttpDeleteHeader", 'i', "is" },
293 {0X5152773B, &WrapI_I<sceHttpDeleteConnection>, "sceHttpDeleteConnection", 'i', "i" },
294 {0X8ACD1F73, &WrapI_IU<sceHttpSetConnectTimeOut>, "sceHttpSetConnectTimeOut", 'i', "ix" },
295 {0X9988172D, &WrapI_IU<sceHttpSetSendTimeOut>, "sceHttpSetSendTimeOut", 'i', "ix" },
296 {0XF0F46C62, &WrapU_UUUUU<sceHttpSetProxy>, "sceHttpSetProxy", 'x', "xxxxx" },
297 {0X0DAFA58F, &WrapI_I<sceHttpEnableCookie>, "sceHttpEnableCookie", 'i', "i" },
298 {0X78A0D3EC, &WrapI_I<sceHttpEnableKeepAlive>, "sceHttpEnableKeepAlive", 'i', "i" },
299 {0X0B12ABFB, &WrapI_I<sceHttpDisableCookie>, "sceHttpDisableCookie", 'i', "i" },
300 {0XC7EF2559, &WrapI_I<sceHttpDisableKeepAlive>, "sceHttpDisableKeepAlive", 'i', "i" },
301 {0XE4D21302, &WrapI_IIII<sceHttpsInit>, "sceHttpsInit", 'i', "iiii" },
302 {0XF9D8EB63, &WrapI_V<sceHttpsEnd>, "sceHttpsEnd", 'i', "" },
303 {0X47347B50, &WrapI_IICU64<sceHttpCreateRequest>, "sceHttpCreateRequest", 'i', "iisX" },
304 {0X8EEFD953, &WrapI_ICCUI<sceHttpCreateConnection>, "sceHttpCreateConnection", 'i', "issxi" },
305 {0XD081EC8F, &WrapI_IU<sceHttpGetNetworkErrno>, "sceHttpGetNetworkErrno", 'i', "ix" },
306 {0X3EABA285, &WrapI_ICCI<sceHttpAddExtraHeader>, "sceHttpAddExtraHeader", 'i', "issi" },
307 {0XC10B6BD9, &WrapI_I<sceHttpAbortRequest>, "sceHttpAbortRequest", 'i', "i" },
308 {0XFCF8C055, &WrapI_I<sceHttpDeleteTemplate>, "sceHttpDeleteTemplate", 'i', "i" },
309 {0XF49934F6, &WrapI_UUU<sceHttpSetMallocFunction>, "sceHttpSetMallocFunction", 'i', "xxx" },
310 {0X03D9526F, &WrapI_II<sceHttpSetResolveRetry>, "sceHttpSetResolveRetry", 'i', "ii" },
311 {0X47940436, &WrapI_IU<sceHttpSetResolveTimeOut>, "sceHttpSetResolveTimeOut", 'i', "ix" },
312 {0X2A6C3296, &WrapI_IU<sceHttpSetAuthInfoCB>, "sceHttpSetAuthInfoCB", 'i', "ix" },
313 {0X0809C831, &WrapI_I<sceHttpEnableRedirect>, "sceHttpEnableRedirect", 'i', "i" },
314 {0X9FC5F10D, &WrapI_I<sceHttpEnableAuth>, "sceHttpEnableAuth", 'i', "i" },
315 {0X1A0EBB69, &WrapI_I<sceHttpDisableRedirect>, "sceHttpDisableRedirect", 'i', "i" },
316 {0XAE948FEE, &WrapI_I<sceHttpDisableAuth>, "sceHttpDisableAuth", 'i', "i" },
317 {0X76D1363B, &WrapI_V<sceHttpSaveSystemCookie>, "sceHttpSaveSystemCookie", 'i', "" },
318 {0X87797BDD, &WrapI_II<sceHttpsLoadDefaultCert>, "sceHttpsLoadDefaultCert", 'i', "ii" },
319 {0XF1657B22, &WrapI_V<sceHttpLoadSystemCookie>, "sceHttpLoadSystemCookie", 'i', "" },
320 {0X9B1F1F36, &WrapI_CII<sceHttpCreateTemplate>, "sceHttpCreateTemplate", 'i', "sii" },
321 {0XB509B09E, &WrapI_IICU64<sceHttpCreateRequestWithURL>, "sceHttpCreateRequestWithURL", 'i', "iisX" },
322 {0XCDF8ECB9, &WrapI_ICI<sceHttpCreateConnectionWithURL>, "sceHttpCreateConnectionWithURL", 'i', "isi" },
323 {0X1F0FC3E3, &WrapI_IU<sceHttpSetRecvTimeOut>, "sceHttpSetRecvTimeOut", 'i', "ix" },
324 {0XDB266CCF, &WrapI_IUU<sceHttpGetAllHeader>, "sceHttpGetAllHeader", 'i', "ixx" },
325 {0X0282A3BD, &WrapI_IU64<sceHttpGetContentLength>, "sceHttpGetContentLength", 'i', "iX" },
326 {0X7774BF4C, nullptr, "sceHttpAddCookie", '?', "" },
327 {0X68AB0F86, nullptr, "sceHttpsInitWithPath", '?', "" },
328 {0XB3FAF831, nullptr, "sceHttpsDisableOption", '?', "" },
329 {0X2255551E, nullptr, "sceHttpGetNetworkPspError", '?', "" },
330 {0XAB1540D5, nullptr, "sceHttpsGetSslError", '?', "" },
331 {0XA4496DE5, nullptr, "sceHttpSetRedirectCallback", '?', "" },
332 {0X267618F4, nullptr, "sceHttpSetAuthInfoCallback", '?', "" },
333 {0X569A1481, nullptr, "sceHttpsSetSslCallback", '?', "" },
334 {0XBAC31BF1, nullptr, "sceHttpsEnableOption", '?', "" },
335 };
336
Register_sceHttp()337 void Register_sceHttp()
338 {
339 RegisterModule("sceHttp",ARRAY_SIZE(sceHttp),sceHttp);
340 }
341