callbacks.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* callbacks.h
  2. *
  3. * Copyright (C) 2006-2023 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. #ifndef WOLFSSL_CALLBACKS_H
  22. #define WOLFSSL_CALLBACKS_H
  23. #include <wolfssl/wolfcrypt/wc_port.h>
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. enum { /* CALLBACK CONSTANTS */
  28. MAX_PACKETNAME_SZ = 24,
  29. MAX_CIPHERNAME_SZ = 24,
  30. MAX_TIMEOUT_NAME_SZ = 24,
  31. MAX_PACKETS_HANDSHAKE = 14, /* 12 for client auth plus 2 alerts */
  32. MAX_VALUE_SZ = 128, /* all handshake packets but Cert should
  33. fit here */
  34. };
  35. struct WOLFSSL;
  36. typedef struct handShakeInfo_st {
  37. struct WOLFSSL* ssl;
  38. char cipherName[MAX_CIPHERNAME_SZ + 1]; /* negotiated cipher */
  39. char packetNames[MAX_PACKETS_HANDSHAKE][MAX_PACKETNAME_SZ + 1];
  40. /* SSL packet names */
  41. int numberPackets; /* actual # of packets */
  42. int negotiationError; /* cipher/parameter err */
  43. } HandShakeInfo;
  44. #if defined(HAVE_SYS_TIME_H) && !defined(NO_TIMEVAL)
  45. typedef struct timeval WOLFSSL_TIMEVAL;
  46. #else /* HAVE_SYS_TIME_H */
  47. /* Define the timeval explicitly. */
  48. typedef struct {
  49. long tv_sec; /* Seconds. */
  50. long tv_usec; /* Microseconds. */
  51. } WOLFSSL_TIMEVAL;
  52. #endif /* HAVE_SYS_TIME_H */
  53. #if !defined(NO_OLD_TIMEVAL_NAME)
  54. #define Timeval WOLFSSL_TIMEVAL
  55. #endif
  56. typedef struct packetInfo_st {
  57. char packetName[MAX_PACKETNAME_SZ + 1]; /* SSL packet name */
  58. WOLFSSL_TIMEVAL timestamp; /* when it occurred */
  59. unsigned char value[MAX_VALUE_SZ]; /* if fits, it's here */
  60. unsigned char* bufferValue; /* otherwise here (non 0) */
  61. int valueSz; /* sz of value or buffer */
  62. } PacketInfo;
  63. typedef struct timeoutInfo_st {
  64. char timeoutName[MAX_TIMEOUT_NAME_SZ + 1]; /* timeout Name */
  65. int flags; /* for future use */
  66. int numberPackets; /* actual # of packets */
  67. PacketInfo packets[MAX_PACKETS_HANDSHAKE]; /* list of all packets */
  68. WOLFSSL_TIMEVAL timeoutValue; /* timer that caused it */
  69. } TimeoutInfo;
  70. #ifdef __cplusplus
  71. } /* extern "C" */
  72. #endif
  73. #endif /* WOLFSSL_CALLBACKS_H */