LCOV - code coverage report
Current view: top level - api/unstable - events.h (source / functions) Hit Total Coverage
Test: unit_test_coverage.info Lines: 1 1 100.0 %
Date: 2026-07-04 07:27:58 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
       3                 :            :  *
       4                 :            :  * Licensed under the Apache License, Version 2.0 (the "License").
       5                 :            :  * You may not use this file except in compliance with the License.
       6                 :            :  * A copy of the License is located at
       7                 :            :  *
       8                 :            :  *  http://aws.amazon.com/apache2.0
       9                 :            :  *
      10                 :            :  * or in the "license" file accompanying this file. This file is distributed
      11                 :            :  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
      12                 :            :  * express or implied. See the License for the specific language governing
      13                 :            :  * permissions and limitations under the License.
      14                 :            :  */
      15                 :            : 
      16                 :            : #pragma once
      17                 :            : 
      18                 :            : #include <s2n.h>
      19                 :            : #include <stdint.h>
      20                 :            : 
      21                 :            : #ifdef __cplusplus
      22                 :            : extern "C" {
      23                 :            : #endif
      24                 :            : 
      25                 :            : /* This is a special value assigned to handshake_start_epoch_ns to indicate that
      26                 :            :  * it has already been sent to the application and should not be sent again.
      27                 :            :  */
      28                 :          3 : #define HANDSHAKE_EVENT_SENT UINT64_C(1) << 63
      29                 :            : 
      30                 :            : struct s2n_event_handshake {
      31                 :            :     /**
      32                 :            :      * The negotiated protocol version
      33                 :            :      * 
      34                 :            :      * This will be one of the protocol version constants defined in s2n.h 
      35                 :            :      */
      36                 :            :     int protocol_version;
      37                 :            :     /* static memory */
      38                 :            :     const char *cipher;
      39                 :            :     /* static memory */
      40                 :            :     const char *group;
      41                 :            :     /* static memory */
      42                 :            :     const char *security_policy_label;
      43                 :            :     /* the amount of time inside the synchronous s2n_negotiate method */
      44                 :            :     uint64_t handshake_time_ns;
      45                 :            :     /**
      46                 :            :      * The start of the handshake. This is not an interpretable time, and only has
      47                 :            :      * meaning in reference to handshake_end_ns. 
      48                 :            :      *
      49                 :            :      * This is also used as a flag to ensure that the same event isn't emitted 
      50                 :            :      * twice. After the event has been emitted this is set to HANDSHAKE_EVENT_SENT
      51                 :            :      */
      52                 :            :     uint64_t handshake_start_ns;
      53                 :            :     uint64_t handshake_end_ns;
      54                 :            :     /**
      55                 :            :      * If the handshake failed, this contains the error code.
      56                 :            :      * 0 indicates no error (successful handshake).
      57                 :            :      * The error name can be retrieved via s2n_strerror_name(error_code).
      58                 :            :      */
      59                 :            :     int error_code;
      60                 :            : };
      61                 :            : 
      62                 :            : typedef void (*s2n_event_on_handshake_cb)(struct s2n_connection *conn, void *subscriber, struct s2n_event_handshake *event);
      63                 :            : 
      64                 :            : S2N_API extern int s2n_config_set_subscriber(struct s2n_config *config, void *subscriber);
      65                 :            : /**
      66                 :            :  * Set a callback to receive a handshake event.
      67                 :            :  * 
      68                 :            :  * The `struct s2n_event_handshake *event` is only valid over the lifetime of the 
      69                 :            :  * callbacks, and must not be referenced after the callback returned.
      70                 :            :  * 
      71                 :            :  * An event is emitted both on success and failure. On failure, the event's
      72                 :            :  * error_code field will be set with the relevant error information.
      73                 :            :  */
      74                 :            : S2N_API extern int s2n_config_set_handshake_event(struct s2n_config *config, s2n_event_on_handshake_cb callback);
      75                 :            : 
      76                 :            : #ifdef __cplusplus
      77                 :            : }
      78                 :            : #endif

Generated by: LCOV version 1.14