lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* callbacks.h |
| 2 | * |
| 3 | * Copyright (C) 2006-2021 wolfSSL Inc. |
| 4 | * |
| 5 | * This file is part of wolfSSL. |
| 6 | * |
| 7 | * wolfSSL is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * wolfSSL is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | |
| 24 | #ifndef WOLFSSL_CALLBACKS_H |
| 25 | #define WOLFSSL_CALLBACKS_H |
| 26 | |
| 27 | #include <wolfssl/wolfcrypt/wc_port.h> |
| 28 | |
| 29 | #ifdef __cplusplus |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
| 33 | |
| 34 | enum { /* CALLBACK CONSTANTS */ |
| 35 | MAX_PACKETNAME_SZ = 24, |
| 36 | MAX_CIPHERNAME_SZ = 24, |
| 37 | MAX_TIMEOUT_NAME_SZ = 24, |
| 38 | MAX_PACKETS_HANDSHAKE = 14, /* 12 for client auth plus 2 alerts */ |
| 39 | MAX_VALUE_SZ = 128, /* all handshake packets but Cert should |
| 40 | fit here */ |
| 41 | }; |
| 42 | |
| 43 | struct WOLFSSL; |
| 44 | |
| 45 | typedef struct handShakeInfo_st { |
| 46 | struct WOLFSSL* ssl; |
| 47 | char cipherName[MAX_CIPHERNAME_SZ + 1]; /* negotiated cipher */ |
| 48 | char packetNames[MAX_PACKETS_HANDSHAKE][MAX_PACKETNAME_SZ + 1]; |
| 49 | /* SSL packet names */ |
| 50 | int numberPackets; /* actual # of packets */ |
| 51 | int negotiationError; /* cipher/parameter err */ |
| 52 | } HandShakeInfo; |
| 53 | |
| 54 | |
| 55 | #if defined(HAVE_SYS_TIME_H) && !defined(NO_TIMEVAL) |
| 56 | typedef struct timeval WOLFSSL_TIMEVAL; |
| 57 | #else /* HAVE_SYS_TIME_H */ |
| 58 | /* Define the timeval explicitly. */ |
| 59 | typedef struct { |
| 60 | long tv_sec; /* Seconds. */ |
| 61 | long tv_usec; /* Microseconds. */ |
| 62 | } WOLFSSL_TIMEVAL; |
| 63 | #endif /* HAVE_SYS_TIME_H */ |
| 64 | #if !defined(NO_OLD_TIMEVAL_NAME) |
| 65 | #define Timeval WOLFSSL_TIMEVAL |
| 66 | #endif |
| 67 | |
| 68 | typedef struct packetInfo_st { |
| 69 | char packetName[MAX_PACKETNAME_SZ + 1]; /* SSL packet name */ |
| 70 | WOLFSSL_TIMEVAL timestamp; /* when it occurred */ |
| 71 | unsigned char value[MAX_VALUE_SZ]; /* if fits, it's here */ |
| 72 | unsigned char* bufferValue; /* otherwise here (non 0) */ |
| 73 | int valueSz; /* sz of value or buffer */ |
| 74 | } PacketInfo; |
| 75 | |
| 76 | |
| 77 | typedef struct timeoutInfo_st { |
| 78 | char timeoutName[MAX_TIMEOUT_NAME_SZ + 1]; /* timeout Name */ |
| 79 | int flags; /* for future use */ |
| 80 | int numberPackets; /* actual # of packets */ |
| 81 | PacketInfo packets[MAX_PACKETS_HANDSHAKE]; /* list of all packets */ |
| 82 | WOLFSSL_TIMEVAL timeoutValue; /* timer that caused it */ |
| 83 | } TimeoutInfo; |
| 84 | |
| 85 | |
| 86 | |
| 87 | #ifdef __cplusplus |
| 88 | } /* extern "C" */ |
| 89 | #endif |
| 90 | |
| 91 | |
| 92 | #endif /* WOLFSSL_CALLBACKS_H */ |
| 93 | |