{"action":"created","comment":{"url":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/comments/105241784","pull_request_review_id":26110883,"id":105241784,"diff_hunk":"@@ -690,92 +527,166 @@ int EmbedGenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *ctx)\n #endif /* WOLFSSL_SESSION_EXPORT */\n #endif /* WOLFSSL_DTLS */\n \n-#ifdef HAVE_OCSP\n+#endif /* USE_WOLFSSL_IO */\n+\n+\n+#if defined(USE_WOLFSSL_IO)\n+\n+#ifndef DEFAULT_TIMEOUT_SEC\n+    #define DEFAULT_TIMEOUT_SEC 0 /* no timeout */\n+#endif\n+\n+#ifdef HAVE_IO_TIMEOUT\n+    static int io_timeout_sec = DEFAULT_TIMEOUT_SEC;\n+#else\n+    #define io_timeout_sec DEFAULT_TIMEOUT_SEC\n+#endif\n+\n \n-#include <stdlib.h>   /* atoi() */\n+void wolfIO_SetTimeout(int to_sec)\n+{\n+#ifdef HAVE_IO_TIMEOUT\n+    io_timeout_sec = to_sec;\n+#else\n+    (void)to_sec;\n+#endif\n+}\n \n+int wolfIO_SetBlockingMode(SOCKET_T sockfd, int non_blocking)\n+{\n+    int ret = 0;\n+\n+#ifdef USE_WINDOWS_API\n+    unsigned long blocking = non_blocking;\n+    ret = ioctlsocket(sockfd, FIONBIO, &blocking);\n+    if (ret == SOCKET_ERROR)\n+        ret = -1;\n+#else\n+    ret = fcntl(sockfd, F_GETFL, 0);\n+    if (ret >= 0) {\n+        if (non_blocking)\n+            ret |= O_NONBLOCK;\n+        else\n+            ret &= ~O_NONBLOCK;\n+        ret = fcntl(sockfd, F_SETFL, ret);\n+    }\n+#endif\n+    if (ret < 0) {\n+        WOLFSSL_MSG(\"wolfIO_SetBlockingMode failed\");\n+    }\n+\n+    return ret;\n+}\n+\n+#ifdef _MSC_VER\n+    /* 4204: non-constant aggregate initializer (nfds = sockfd + 1) */\n+    #pragma warning(disable: 4204)\n+#endif\n+int wolfIO_Select(SOCKET_T sockfd, int to_sec)\n+{\n+    fd_set fds;\n+    SOCKET_T nfds = sockfd + 1;\n+    struct timeval timeout = { (to_sec > 0) ? to_sec : 0, 0};\n+    int ret;\n+\n+    FD_ZERO(&fds);\n+    FD_SET(sockfd, &fds);\n+\n+    ret = select(nfds, &fds, &fds, NULL, &timeout);\n+    if (ret == 0) {\n+    #ifdef DEBUG_HTTP\n+        printf(\"Timeout: %d\\n\", ret);\n+    #endif\n+        return HTTP_TIMEOUT;\n+    }\n+    else if (ret > 0) {\n+        if (FD_ISSET(sockfd, &fds))\n+            return 0;\n+    }\n+    return SOCKET_ERROR_E;\n+}\n \n-static int Word16ToString(char* d, word16 number)\n+static int wolfIO_Word16ToString(char* d, word16 number)\n {\n     int i = 0;\n+    word16 order = 10000;\n+    word16 digit;\n \n-    if (d != NULL) {\n-        word16 order = 10000;\n-        word16 digit;\n+    if (d == NULL)\n+        return i;\n \n-        if (number == 0) {\n-            d[i++] = '0';\n-        }\n-        else {\n-            while (order) {\n-                digit = number / order;\n-                if (i > 0 || digit != 0) {\n-                    d[i++] = (char)digit + '0';\n-                }\n-                if (digit != 0)\n-                    number %= digit * order;\n-                if (order > 1)\n-                    order /= 10;\n-                else\n-                    order = 0;\n-            }\n+    if (number == 0)\n+        d[i++] = '0';\n+    else {\n+        while (order) {\n+            digit = number / order;\n+            if (i > 0 || digit != 0)\n+                d[i++] = (char)digit + '0';\n+            if (digit != 0)\n+                number %= digit * order;\n+\n+            order = (order > 1) ? order / 10 : 0;\n         }\n-        d[i] = 0;\n     }\n+    d[i] = 0; /* null terminate */\n \n     return i;\n }\n \n-\n-static int tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port)\n+int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)\n {\n+    int ret = 0;\n     struct sockaddr_storage addr;","path":"src/io.c","position":397,"original_position":397,"commit_id":"3a7b34354f596ef450d0103284279a4b248cd46f","original_commit_id":"3a7b34354f596ef450d0103284279a4b248cd46f","user":{"login":"toddouska","id":601574,"avatar_url":"https://avatars2.githubusercontent.com/u/601574?v=3","gravatar_id":"","url":"https://api.github.com/users/toddouska","html_url":"https://github.com/toddouska","followers_url":"https://api.github.com/users/toddouska/followers","following_url":"https://api.github.com/users/toddouska/following{/other_user}","gists_url":"https://api.github.com/users/toddouska/gists{/gist_id}","starred_url":"https://api.github.com/users/toddouska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toddouska/subscriptions","organizations_url":"https://api.github.com/users/toddouska/orgs","repos_url":"https://api.github.com/users/toddouska/repos","events_url":"https://api.github.com/users/toddouska/events{/privacy}","received_events_url":"https://api.github.com/users/toddouska/received_events","type":"User","site_admin":false},"body":"An embedded platform may not have sockaddr_storage.","created_at":"2017-03-09T18:54:05Z","updated_at":"2017-03-09T18:55:44Z","html_url":"https://github.com/wolfSSL/wolfssl/pull/768#discussion_r105241784","pull_request_url":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/768","_links":{"self":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/comments/105241784"},"html":{"href":"https://github.com/wolfSSL/wolfssl/pull/768#discussion_r105241784"},"pull_request":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/768"}}},"pull_request":{"url":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/768","id":108236826,"html_url":"https://github.com/wolfSSL/wolfssl/pull/768","diff_url":"https://github.com/wolfSSL/wolfssl/pull/768.diff","patch_url":"https://github.com/wolfSSL/wolfssl/pull/768.patch","issue_url":"https://api.github.com/repos/wolfSSL/wolfssl/issues/768","number":768,"state":"open","locked":false,"title":"Added support for inline CRL lookup when HAVE_CRL_IO is defined","user":{"login":"dgarske","id":2692870,"avatar_url":"https://avatars3.githubusercontent.com/u/2692870?v=3","gravatar_id":"","url":"https://api.github.com/users/dgarske","html_url":"https://github.com/dgarske","followers_url":"https://api.github.com/users/dgarske/followers","following_url":"https://api.github.com/users/dgarske/following{/other_user}","gists_url":"https://api.github.com/users/dgarske/gists{/gist_id}","starred_url":"https://api.github.com/users/dgarske/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgarske/subscriptions","organizations_url":"https://api.github.com/users/dgarske/orgs","repos_url":"https://api.github.com/users/dgarske/repos","events_url":"https://api.github.com/users/dgarske/events{/privacy}","received_events_url":"https://api.github.com/users/dgarske/received_events","type":"User","site_admin":false},"body":"Added support for inline CRL lookup when HAVE_CRL_IO is defined (shares code with OCSP lookup in io.c). Added http chunk transfer encoding support. Added default connection timeout value (DEFAULT_TIMEOUT_SEC) and new wolfIO_SetTimeout() API with HAVE_IO_TIMEOUT. Added generic wolfIO_ API’s for connect, select, non-blocking, read and write. Added new define USE_WOLFSSL_IO to enable access to new wolfIO_* socket wrappers even when WOLFSSL_USER_IO is defined. Moved all API declarations for io.c into new io.h header. Added HAVE_HTTP_CLIENT to expose HTTP API’s. Moved SOCKET_T and SOCKET_ defines into io.h. Added WOLFIO_DEBUG define to display request/responses.","created_at":"2017-02-28T01:03:27Z","updated_at":"2017-03-09T18:55:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db9e2406a966f8ab7519314a8c995dbb376bd22c","assignee":{"login":"toddouska","id":601574,"avatar_url":"https://avatars2.githubusercontent.com/u/601574?v=3","gravatar_id":"","url":"https://api.github.com/users/toddouska","html_url":"https://github.com/toddouska","followers_url":"https://api.github.com/users/toddouska/followers","following_url":"https://api.github.com/users/toddouska/following{/other_user}","gists_url":"https://api.github.com/users/toddouska/gists{/gist_id}","starred_url":"https://api.github.com/users/toddouska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toddouska/subscriptions","organizations_url":"https://api.github.com/users/toddouska/orgs","repos_url":"https://api.github.com/users/toddouska/repos","events_url":"https://api.github.com/users/toddouska/events{/privacy}","received_events_url":"https://api.github.com/users/toddouska/received_events","type":"User","site_admin":false},"assignees":[{"login":"toddouska","id":601574,"avatar_url":"https://avatars2.githubusercontent.com/u/601574?v=3","gravatar_id":"","url":"https://api.github.com/users/toddouska","html_url":"https://github.com/toddouska","followers_url":"https://api.github.com/users/toddouska/followers","following_url":"https://api.github.com/users/toddouska/following{/other_user}","gists_url":"https://api.github.com/users/toddouska/gists{/gist_id}","starred_url":"https://api.github.com/users/toddouska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toddouska/subscriptions","organizations_url":"https://api.github.com/users/toddouska/orgs","repos_url":"https://api.github.com/users/toddouska/repos","events_url":"https://api.github.com/users/toddouska/events{/privacy}","received_events_url":"https://api.github.com/users/toddouska/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/768/commits","review_comments_url":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/768/comments","review_comment_url":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wolfSSL/wolfssl/issues/768/comments","statuses_url":"https://api.github.com/repos/wolfSSL/wolfssl/statuses/3a7b34354f596ef450d0103284279a4b248cd46f","head":{"label":"dgarske:crl_lookup","ref":"crl_lookup","sha":"3a7b34354f596ef450d0103284279a4b248cd46f","user":{"login":"dgarske","id":2692870,"avatar_url":"https://avatars3.githubusercontent.com/u/2692870?v=3","gravatar_id":"","url":"https://api.github.com/users/dgarske","html_url":"https://github.com/dgarske","followers_url":"https://api.github.com/users/dgarske/followers","following_url":"https://api.github.com/users/dgarske/following{/other_user}","gists_url":"https://api.github.com/users/dgarske/gists{/gist_id}","starred_url":"https://api.github.com/users/dgarske/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgarske/subscriptions","organizations_url":"https://api.github.com/users/dgarske/orgs","repos_url":"https://api.github.com/users/dgarske/repos","events_url":"https://api.github.com/users/dgarske/events{/privacy}","received_events_url":"https://api.github.com/users/dgarske/received_events","type":"User","site_admin":false},"repo":{"id":44402104,"name":"wolfssl","full_name":"dgarske/wolfssl","owner":{"login":"dgarske","id":2692870,"avatar_url":"https://avatars3.githubusercontent.com/u/2692870?v=3","gravatar_id":"","url":"https://api.github.com/users/dgarske","html_url":"https://github.com/dgarske","followers_url":"https://api.github.com/users/dgarske/followers","following_url":"https://api.github.com/users/dgarske/following{/other_user}","gists_url":"https://api.github.com/users/dgarske/gists{/gist_id}","starred_url":"https://api.github.com/users/dgarske/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgarske/subscriptions","organizations_url":"https://api.github.com/users/dgarske/orgs","repos_url":"https://api.github.com/users/dgarske/repos","events_url":"https://api.github.com/users/dgarske/events{/privacy}","received_events_url":"https://api.github.com/users/dgarske/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dgarske/wolfssl","description":"wolfSSL (formerly CyaSSL) is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. http://www.wolfssl.com","fork":true,"url":"https://api.github.com/repos/dgarske/wolfssl","forks_url":"https://api.github.com/repos/dgarske/wolfssl/forks","keys_url":"https://api.github.com/repos/dgarske/wolfssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgarske/wolfssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgarske/wolfssl/teams","hooks_url":"https://api.github.com/repos/dgarske/wolfssl/hooks","issue_events_url":"https://api.github.com/repos/dgarske/wolfssl/issues/events{/number}","events_url":"https://api.github.com/repos/dgarske/wolfssl/events","assignees_url":"https://api.github.com/repos/dgarske/wolfssl/assignees{/user}","branches_url":"https://api.github.com/repos/dgarske/wolfssl/branches{/branch}","tags_url":"https://api.github.com/repos/dgarske/wolfssl/tags","blobs_url":"https://api.github.com/repos/dgarske/wolfssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgarske/wolfssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgarske/wolfssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgarske/wolfssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgarske/wolfssl/statuses/{sha}","languages_url":"https://api.github.com/repos/dgarske/wolfssl/languages","stargazers_url":"https://api.github.com/repos/dgarske/wolfssl/stargazers","contributors_url":"https://api.github.com/repos/dgarske/wolfssl/contributors","subscribers_url":"https://api.github.com/repos/dgarske/wolfssl/subscribers","subscription_url":"https://api.github.com/repos/dgarske/wolfssl/subscription","commits_url":"https://api.github.com/repos/dgarske/wolfssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgarske/wolfssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgarske/wolfssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgarske/wolfssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgarske/wolfssl/contents/{+path}","compare_url":"https://api.github.com/repos/dgarske/wolfssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgarske/wolfssl/merges","archive_url":"https://api.github.com/repos/dgarske/wolfssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgarske/wolfssl/downloads","issues_url":"https://api.github.com/repos/dgarske/wolfssl/issues{/number}","pulls_url":"https://api.github.com/repos/dgarske/wolfssl/pulls{/number}","milestones_url":"https://api.github.com/repos/dgarske/wolfssl/milestones{/number}","notifications_url":"https://api.github.com/repos/dgarske/wolfssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgarske/wolfssl/labels{/name}","releases_url":"https://api.github.com/repos/dgarske/wolfssl/releases{/id}","deployments_url":"https://api.github.com/repos/dgarske/wolfssl/deployments","created_at":"2015-10-16T18:00:02Z","updated_at":"2016-10-25T20:06:59Z","pushed_at":"2017-03-09T05:13:54Z","git_url":"git://github.com/dgarske/wolfssl.git","ssh_url":"git@github.com:dgarske/wolfssl.git","clone_url":"https://github.com/dgarske/wolfssl.git","svn_url":"https://github.com/dgarske/wolfssl","homepage":null,"size":26556,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wolfSSL:master","ref":"master","sha":"df32c6fb0b2ff83733bc6bece0f9717e85310ab7","user":{"login":"wolfSSL","id":5891092,"avatar_url":"https://avatars3.githubusercontent.com/u/5891092?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfSSL","html_url":"https://github.com/wolfSSL","followers_url":"https://api.github.com/users/wolfSSL/followers","following_url":"https://api.github.com/users/wolfSSL/following{/other_user}","gists_url":"https://api.github.com/users/wolfSSL/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfSSL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfSSL/subscriptions","organizations_url":"https://api.github.com/users/wolfSSL/orgs","repos_url":"https://api.github.com/users/wolfSSL/repos","events_url":"https://api.github.com/users/wolfSSL/events{/privacy}","received_events_url":"https://api.github.com/users/wolfSSL/received_events","type":"Organization","site_admin":false},"repo":{"id":28928522,"name":"wolfssl","full_name":"wolfSSL/wolfssl","owner":{"login":"wolfSSL","id":5891092,"avatar_url":"https://avatars3.githubusercontent.com/u/5891092?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfSSL","html_url":"https://github.com/wolfSSL","followers_url":"https://api.github.com/users/wolfSSL/followers","following_url":"https://api.github.com/users/wolfSSL/following{/other_user}","gists_url":"https://api.github.com/users/wolfSSL/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfSSL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfSSL/subscriptions","organizations_url":"https://api.github.com/users/wolfSSL/orgs","repos_url":"https://api.github.com/users/wolfSSL/repos","events_url":"https://api.github.com/users/wolfSSL/events{/privacy}","received_events_url":"https://api.github.com/users/wolfSSL/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wolfSSL/wolfssl","description":"wolfSSL (formerly CyaSSL) is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. http://www.wolfssl.com","fork":false,"url":"https://api.github.com/repos/wolfSSL/wolfssl","forks_url":"https://api.github.com/repos/wolfSSL/wolfssl/forks","keys_url":"https://api.github.com/repos/wolfSSL/wolfssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wolfSSL/wolfssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wolfSSL/wolfssl/teams","hooks_url":"https://api.github.com/repos/wolfSSL/wolfssl/hooks","issue_events_url":"https://api.github.com/repos/wolfSSL/wolfssl/issues/events{/number}","events_url":"https://api.github.com/repos/wolfSSL/wolfssl/events","assignees_url":"https://api.github.com/repos/wolfSSL/wolfssl/assignees{/user}","branches_url":"https://api.github.com/repos/wolfSSL/wolfssl/branches{/branch}","tags_url":"https://api.github.com/repos/wolfSSL/wolfssl/tags","blobs_url":"https://api.github.com/repos/wolfSSL/wolfssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wolfSSL/wolfssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wolfSSL/wolfssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/wolfSSL/wolfssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wolfSSL/wolfssl/statuses/{sha}","languages_url":"https://api.github.com/repos/wolfSSL/wolfssl/languages","stargazers_url":"https://api.github.com/repos/wolfSSL/wolfssl/stargazers","contributors_url":"https://api.github.com/repos/wolfSSL/wolfssl/contributors","subscribers_url":"https://api.github.com/repos/wolfSSL/wolfssl/subscribers","subscription_url":"https://api.github.com/repos/wolfSSL/wolfssl/subscription","commits_url":"https://api.github.com/repos/wolfSSL/wolfssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/wolfSSL/wolfssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/wolfSSL/wolfssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/wolfSSL/wolfssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/wolfSSL/wolfssl/contents/{+path}","compare_url":"https://api.github.com/repos/wolfSSL/wolfssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wolfSSL/wolfssl/merges","archive_url":"https://api.github.com/repos/wolfSSL/wolfssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wolfSSL/wolfssl/downloads","issues_url":"https://api.github.com/repos/wolfSSL/wolfssl/issues{/number}","pulls_url":"https://api.github.com/repos/wolfSSL/wolfssl/pulls{/number}","milestones_url":"https://api.github.com/repos/wolfSSL/wolfssl/milestones{/number}","notifications_url":"https://api.github.com/repos/wolfSSL/wolfssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wolfSSL/wolfssl/labels{/name}","releases_url":"https://api.github.com/repos/wolfSSL/wolfssl/releases{/id}","deployments_url":"https://api.github.com/repos/wolfSSL/wolfssl/deployments","created_at":"2015-01-07T18:50:58Z","updated_at":"2017-03-08T14:15:03Z","pushed_at":"2017-03-09T18:23:21Z","git_url":"git://github.com/wolfSSL/wolfssl.git","ssh_url":"git@github.com:wolfSSL/wolfssl.git","clone_url":"https://github.com/wolfSSL/wolfssl.git","svn_url":"https://github.com/wolfSSL/wolfssl","homepage":null,"size":26067,"stargazers_count":201,"watchers_count":201,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":95,"mirror_url":null,"open_issues_count":42,"forks":95,"open_issues":42,"watchers":201,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/768"},"html":{"href":"https://github.com/wolfSSL/wolfssl/pull/768"},"issue":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/issues/768"},"comments":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/issues/768/comments"},"review_comments":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/768/comments"},"review_comment":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/pulls/768/commits"},"statuses":{"href":"https://api.github.com/repos/wolfSSL/wolfssl/statuses/3a7b34354f596ef450d0103284279a4b248cd46f"}}}}
{"actor":{"display_login":"toddouska"}}