1 /*---------------------------------------------------------------------------* 2 3 Copyright (C)2009-2013 Nintendo. All rights reserved. 4 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 11 *---------------------------------------------------------------------------*/ 12 #ifndef __NETTEST_H__ 13 #define __NETTEST_H__ 14 15 #include <types.h> 16 #ifndef IOP_BUILD 17 #include <private/IPCDriverInterface.h> 18 #endif 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 /*---------------------------------------------------------------------------* 23 * 24 * Constants defined for this file 25 * -- #Defines's -- 26 * 27 *---------------------------------------------------------------------------*/ 28 #define NETTEST_ROUNDUP( value, alignment ) \ 29 ((((u32)(value)) + ((alignment)-1)) & ~((alignment)-1)) 30 31 #define NETTEST_IPCBUF_SIZE 512 32 #define URL_STRING_LEN 192 33 34 35 #if defined(IOP_BUILD) 36 #define NETTEST_PADDING_DECLARATION(dataType, padName) 37 #else 38 #define NETTEST_PADDING_DECLARATION(dataType, padName) \ 39 IPC_USER_DATA_STRUCTURE_PADDING_DECLARATION(dataType, padName) 40 #endif 41 42 /*---------------------------------------------------------------------------* 43 * 44 * Data types defined for this file 45 * -- Struct's, Typedef's, Enum's -- 46 * 47 *---------------------------------------------------------------------------*/ 48 49 typedef enum { 50 NETTEST_ERROR_OK = 0, 51 NETTEST_ERROR_NG = -1, 52 NETTEST_ERROR_NEED_INT = -2, 53 NETTEST_ERROR_RETRY = -3, 54 NETTEST_ERROR_NOMEM = -4, 55 } NETTEST_ERROR; 56 57 typedef enum { 58 NETTEST_TEST_TYPE_HTTP_DOWNLOAD = 1, 59 NETTEST_TEST_TYPE_SOCKET_DOWNLOAD, 60 NETTEST_TEST_TYPE_SOCKET_CLOSE_ALL, 61 NETTEST_TEST_TYPE_MAX, 62 } NETTEST_TEST_TYPE; 63 64 /*---------------------------------------------------------------------------* 65 structure 66 *---------------------------------------------------------------------------*/ 67 typedef struct nettest_http_download_ 68 { 69 u8 url[URL_STRING_LEN]; 70 u32 so_rcvbuf_size; 71 u32 so_winscale; 72 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) nettest_http_download_t; 73 74 typedef struct nettest_http_download_reply_ 75 { 76 u32 curl_status_code; 77 u32 http_status_code; 78 u32 download_size; 79 u32 elapsed_time; 80 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) nettest_http_download_reply_t; 81 82 typedef struct nettest_socket_download_ 83 { 84 u32 port; 85 char address[16]; 86 u32 max_recv_size; 87 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) nettest_socket_download_t; 88 89 typedef struct http_download_ctx_ { 90 IOSIoVector iov[2]; 91 NETTEST_PADDING_DECLARATION(IOSIoVector[4], iovPad); 92 nettest_http_download_t args; 93 } PACKED_STRUCT_ATTRIBUTE http_download_ctx_t; 94 95 /*---------------------------------------------------------------------------* 96 * 97 * -- Interface Function Prototypes -- 98 * 99 *---------------------------------------------------------------------------*/ 100 extern NETTEST_ERROR NETTESTInit (void); 101 extern NETTEST_ERROR NETTESTClose (void); 102 extern NETTEST_ERROR NETTESTHttpDownload (nettest_http_download_t* args, nettest_http_download_reply_t* reply); 103 extern NETTEST_ERROR NETTESTSocketDownload (nettest_socket_download_t* args, nettest_http_download_reply_t* reply); 104 extern NETTEST_ERROR NETTESTSocketCloseAll (void); 105 extern BOOL NATF_speed_test(const char* pUrl, unsigned nTimesToDownload, unsigned nNumConnections, unsigned nMinBandwidthMbits); 106 107 #ifdef __cplusplus 108 } 109 #endif 110 111 #endif // __NETTEST_H__ 112