wolfSSL 3.11.1 for TLS1.3 beta

Fork of wolfSSL by wolf SSL

Committer:
wolfSSL
Date:
Tue May 30 01:44:10 2017 +0000
Revision:
11:cee25a834751
wolfSSL 3.11.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 11:cee25a834751 1 /* wolfevent.h
wolfSSL 11:cee25a834751 2 *
wolfSSL 11:cee25a834751 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 11:cee25a834751 4 *
wolfSSL 11:cee25a834751 5 * This file is part of wolfSSL.
wolfSSL 11:cee25a834751 6 *
wolfSSL 11:cee25a834751 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 11:cee25a834751 8 * it under the terms of the GNU General Public License as published by
wolfSSL 11:cee25a834751 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 11:cee25a834751 10 * (at your option) any later version.
wolfSSL 11:cee25a834751 11 *
wolfSSL 11:cee25a834751 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 11:cee25a834751 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 11:cee25a834751 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 11:cee25a834751 15 * GNU General Public License for more details.
wolfSSL 11:cee25a834751 16 *
wolfSSL 11:cee25a834751 17 * You should have received a copy of the GNU General Public License
wolfSSL 11:cee25a834751 18 * along with this program; if not, write to the Free Software
wolfSSL 11:cee25a834751 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 11:cee25a834751 20 */
wolfSSL 11:cee25a834751 21
wolfSSL 11:cee25a834751 22 #ifndef _WOLF_EVENT_H_
wolfSSL 11:cee25a834751 23 #define _WOLF_EVENT_H_
wolfSSL 11:cee25a834751 24
wolfSSL 11:cee25a834751 25 #ifdef __cplusplus
wolfSSL 11:cee25a834751 26 extern "C" {
wolfSSL 11:cee25a834751 27 #endif
wolfSSL 11:cee25a834751 28
wolfSSL 11:cee25a834751 29 #ifndef SINGLE_THREADED
wolfSSL 11:cee25a834751 30 #include <wolfssl/wolfcrypt/wc_port.h>
wolfSSL 11:cee25a834751 31 #endif
wolfSSL 11:cee25a834751 32 #ifdef HAVE_CAVIUM
wolfSSL 11:cee25a834751 33 #include <wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h>
wolfSSL 11:cee25a834751 34 #endif
wolfSSL 11:cee25a834751 35
wolfSSL 11:cee25a834751 36 typedef struct WOLFSSL WOLFSSL;
wolfSSL 11:cee25a834751 37 typedef struct WOLF_EVENT WOLF_EVENT;
wolfSSL 11:cee25a834751 38 typedef struct WOLFSSL_CTX WOLFSSL_CTX;
wolfSSL 11:cee25a834751 39
wolfSSL 11:cee25a834751 40 typedef unsigned short WOLF_EVENT_FLAG;
wolfSSL 11:cee25a834751 41
wolfSSL 11:cee25a834751 42 typedef enum WOLF_EVENT_TYPE {
wolfSSL 11:cee25a834751 43 WOLF_EVENT_TYPE_NONE,
wolfSSL 11:cee25a834751 44 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 11:cee25a834751 45 WOLF_EVENT_TYPE_ASYNC_WOLFSSL, /* context is WOLFSSL* */
wolfSSL 11:cee25a834751 46 WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT, /* context is WC_ASYNC_DEV */
wolfSSL 11:cee25a834751 47 WOLF_EVENT_TYPE_ASYNC_FIRST = WOLF_EVENT_TYPE_ASYNC_WOLFSSL,
wolfSSL 11:cee25a834751 48 WOLF_EVENT_TYPE_ASYNC_LAST = WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT,
wolfSSL 11:cee25a834751 49 #endif /* WOLFSSL_ASYNC_CRYPT */
wolfSSL 11:cee25a834751 50 } WOLF_EVENT_TYPE;
wolfSSL 11:cee25a834751 51
wolfSSL 11:cee25a834751 52 struct WOLF_EVENT {
wolfSSL 11:cee25a834751 53 /* double linked list */
wolfSSL 11:cee25a834751 54 WOLF_EVENT* next;
wolfSSL 11:cee25a834751 55 WOLF_EVENT* prev;
wolfSSL 11:cee25a834751 56
wolfSSL 11:cee25a834751 57 void* context;
wolfSSL 11:cee25a834751 58 union {
wolfSSL 11:cee25a834751 59 void* ptr;
wolfSSL 11:cee25a834751 60 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 11:cee25a834751 61 struct WC_ASYNC_DEV* async;
wolfSSL 11:cee25a834751 62 #endif
wolfSSL 11:cee25a834751 63 } dev;
wolfSSL 11:cee25a834751 64 #ifdef HAVE_CAVIUM
wolfSSL 11:cee25a834751 65 CavReqId reqId;
wolfSSL 11:cee25a834751 66 #endif
wolfSSL 11:cee25a834751 67 int ret; /* Async return code */
wolfSSL 11:cee25a834751 68 unsigned int flags;
wolfSSL 11:cee25a834751 69 WOLF_EVENT_TYPE type;
wolfSSL 11:cee25a834751 70
wolfSSL 11:cee25a834751 71 /* event flags */
wolfSSL 11:cee25a834751 72 WOLF_EVENT_FLAG pending:1;
wolfSSL 11:cee25a834751 73 WOLF_EVENT_FLAG done:1;
wolfSSL 11:cee25a834751 74 /* Future event flags can go here */
wolfSSL 11:cee25a834751 75 };
wolfSSL 11:cee25a834751 76
wolfSSL 11:cee25a834751 77 enum WOLF_POLL_FLAGS {
wolfSSL 11:cee25a834751 78 WOLF_POLL_FLAG_CHECK_HW = 0x01,
wolfSSL 11:cee25a834751 79 };
wolfSSL 11:cee25a834751 80
wolfSSL 11:cee25a834751 81 typedef struct {
wolfSSL 11:cee25a834751 82 WOLF_EVENT* head; /* head of queue */
wolfSSL 11:cee25a834751 83 WOLF_EVENT* tail; /* tail of queue */
wolfSSL 11:cee25a834751 84 #ifndef SINGLE_THREADED
wolfSSL 11:cee25a834751 85 wolfSSL_Mutex lock; /* queue lock */
wolfSSL 11:cee25a834751 86 #endif
wolfSSL 11:cee25a834751 87 int count;
wolfSSL 11:cee25a834751 88 } WOLF_EVENT_QUEUE;
wolfSSL 11:cee25a834751 89
wolfSSL 11:cee25a834751 90
wolfSSL 11:cee25a834751 91 #ifdef HAVE_WOLF_EVENT
wolfSSL 11:cee25a834751 92
wolfSSL 11:cee25a834751 93 /* Event */
wolfSSL 11:cee25a834751 94 WOLFSSL_API int wolfEvent_Init(WOLF_EVENT* event, WOLF_EVENT_TYPE type, void* context);
wolfSSL 11:cee25a834751 95 WOLFSSL_API int wolfEvent_Poll(WOLF_EVENT* event, WOLF_EVENT_FLAG flags);
wolfSSL 11:cee25a834751 96
wolfSSL 11:cee25a834751 97 /* Event Queue */
wolfSSL 11:cee25a834751 98 WOLFSSL_API int wolfEventQueue_Init(WOLF_EVENT_QUEUE* queue);
wolfSSL 11:cee25a834751 99 WOLFSSL_API int wolfEventQueue_Push(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event);
wolfSSL 11:cee25a834751 100 WOLFSSL_API int wolfEventQueue_Pop(WOLF_EVENT_QUEUE* queue, WOLF_EVENT** event);
wolfSSL 11:cee25a834751 101 WOLFSSL_API int wolfEventQueue_Poll(WOLF_EVENT_QUEUE* queue, void* context_filter,
wolfSSL 11:cee25a834751 102 WOLF_EVENT** events, int maxEvents, WOLF_EVENT_FLAG flags, int* eventCount);
wolfSSL 11:cee25a834751 103 WOLFSSL_API int wolfEventQueue_Count(WOLF_EVENT_QUEUE* queue);
wolfSSL 11:cee25a834751 104 WOLFSSL_API void wolfEventQueue_Free(WOLF_EVENT_QUEUE* queue);
wolfSSL 11:cee25a834751 105
wolfSSL 11:cee25a834751 106 /* the queue mutex must be locked prior to calling these */
wolfSSL 11:cee25a834751 107 WOLFSSL_API int wolfEventQueue_Add(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event);
wolfSSL 11:cee25a834751 108 WOLFSSL_API int wolfEventQueue_Remove(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event);
wolfSSL 11:cee25a834751 109
wolfSSL 11:cee25a834751 110
wolfSSL 11:cee25a834751 111 #endif /* HAVE_WOLF_EVENT */
wolfSSL 11:cee25a834751 112
wolfSSL 11:cee25a834751 113
wolfSSL 11:cee25a834751 114 #ifdef __cplusplus
wolfSSL 11:cee25a834751 115 } /* extern "C" */
wolfSSL 11:cee25a834751 116 #endif
wolfSSL 11:cee25a834751 117
wolfSSL 11:cee25a834751 118 #endif /* _WOLF_EVENT_H_ */
wolfSSL 11:cee25a834751 119