Skip to content

Introduce struct ngtcp2_path_challenge_data#2042

Merged
tatsuhiro-t merged 1 commit intomainfrom
struct-path-challenge-data
Mar 1, 2026
Merged

Introduce struct ngtcp2_path_challenge_data#2042
tatsuhiro-t merged 1 commit intomainfrom
struct-path-challenge-data

Conversation

@tatsuhiro-t
Copy link
Copy Markdown
Member

This commit introduces struct ngtcp2_path_challenge_data just like ngtcp2_stateless_reset_token in earlier commits.

This commit deprecates ngtcp2_get_path_challenge_data. It adds ngtcp2_get_path_challenge_data2 as a replacement.

This commit deprecates ngtcp2_crypto_get_path_challenge_data_cb. It adds ngtcp2_crypto_get_path_challenge_data2_cb as a replacement.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the handling of path challenge data within the ngtcp2 library by introducing a dedicated ngtcp2_path_challenge_data struct. This change aims to standardize how path challenge data is passed and managed, leading to a more robust and maintainable codebase. The existing API for retrieving path challenge data has been deprecated in favor of new functions and callbacks that leverage this new struct, ensuring a clear migration path for users while enhancing internal data consistency.

Highlights

  • New Data Structure for Path Challenge: Introduced struct ngtcp2_path_challenge_data to encapsulate path challenge data, improving type safety and consistency across the library.
  • API Deprecation and Replacement: Deprecated the old ngtcp2_get_path_challenge_data function and ngtcp2_crypto_get_path_challenge_data_cb callback, replacing them with ngtcp2_get_path_challenge_data2 and ngtcp2_crypto_get_path_challenge_data2_cb respectively, which now utilize the new ngtcp2_path_challenge_data struct.
  • Widespread Integration: Updated all relevant crypto backends (BoringSSL, GnuTLS, OpenSSL, PicoTLS, WolfSSL), core connection logic, packet handling, path validation, logging, examples, and fuzzing code to adopt the new data structure and its associated API.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • crypto/boringssl/boringssl.c
    • Added ngtcp2_crypto_get_path_challenge_data2_cb to generate path challenge data using the new struct.
  • crypto/gnutls/gnutls.c
    • Added ngtcp2_crypto_get_path_challenge_data2_cb to generate path challenge data using the new struct.
  • crypto/includes/ngtcp2/ngtcp2_crypto.h
    • Deprecated ngtcp2_crypto_get_path_challenge_data_cb.
    • Declared ngtcp2_crypto_get_path_challenge_data2_cb with the new ngtcp2_path_challenge_data struct.
  • crypto/ossl/ossl.c
    • Added ngtcp2_crypto_get_path_challenge_data2_cb to generate path challenge data using the new struct.
  • crypto/picotls/picotls.c
    • Added ngtcp2_crypto_get_path_challenge_data2_cb to generate path challenge data using the new struct.
  • crypto/quictls/quictls.c
    • Added ngtcp2_crypto_get_path_challenge_data2_cb to generate path challenge data using the new struct.
  • crypto/wolfssl/wolfssl.c
    • Added ngtcp2_crypto_get_path_challenge_data2_cb to generate path challenge data using the new struct.
  • doc/source/programmers-guide.rst
    • Updated documentation to reference the new get_path_challenge_data2 callback.
  • examples/client.cc
    • Updated callback assignment to use ngtcp2_crypto_get_path_challenge_data2_cb.
  • examples/gtlssimpleclient.c
    • Updated callback assignment to use ngtcp2_crypto_get_path_challenge_data2_cb.
  • examples/h09client.cc
    • Updated callback assignment to use ngtcp2_crypto_get_path_challenge_data2_cb.
  • examples/h09server.cc
    • Updated callback assignment to use ngtcp2_crypto_get_path_challenge_data2_cb.
  • examples/server.cc
    • Updated callback assignment to use ngtcp2_crypto_get_path_challenge_data2_cb.
  • examples/sim.cc
    • Updated callback assignments to use ngtcp2_crypto_get_path_challenge_data2_cb in both client and server default callbacks.
  • examples/simpleclient.c
    • Updated callback assignment to use ngtcp2_crypto_get_path_challenge_data2_cb.
  • fuzz/read_write_handshake_pkt.cc
    • Implemented get_path_challenge_data2 to handle path challenge data.
    • Updated callback assignment to use get_path_challenge_data2.
  • fuzz/read_write_pkt.cc
    • Implemented get_path_challenge_data2 to handle path challenge data.
    • Updated callback assignment to use get_path_challenge_data2.
    • Added fuzzer logic to optionally set get_path_challenge_data2 to null.
  • lib/includes/ngtcp2/ngtcp2.h
    • Deprecated ngtcp2_get_path_challenge_data typedef.
    • Introduced ngtcp2_path_challenge_data struct.
    • Introduced ngtcp2_get_path_challenge_data2 typedef.
    • Updated ngtcp2_callbacks struct to include get_path_challenge_data2 and deprecated the old get_path_challenge_data.
  • lib/ngtcp2_conn.c
    • Modified conn_call_get_path_challenge_data to conditionally call get_path_challenge_data2 if available, falling back to the deprecated get_path_challenge_data.
    • Updated assertions in conn_new to check for either get_path_challenge_data2 or get_path_challenge_data.
    • Adjusted PATH_RESPONSE frame initialization to use the new ngtcp2_path_response struct literal.
    • Modified conn_write_path_challenge to pass ngtcp2_path_challenge_data by reference.
    • Updated ngtcp2_pv_add_entry call to pass ngtcp2_path_challenge_data by reference.
    • Modified conn_recv_path_challenge to pass ngtcp2_path_challenge_data by reference.
    • Modified conn_recv_path_response to pass ngtcp2_path_challenge_data by reference.
    • Updated ngtcp2_path_challenge_entry_init signature and data assignment to use the new struct.
  • lib/ngtcp2_conn.h
    • Updated ngtcp2_path_challenge_entry struct to embed ngtcp2_path_challenge_data.
    • Modified ngtcp2_path_challenge_entry_init function signature to accept ngtcp2_path_challenge_data.
  • lib/ngtcp2_log.c
    • Updated log_fr_path_challenge and log_fr_path_response to access frame data through the data member of ngtcp2_path_challenge_data.
  • lib/ngtcp2_pkt.c
    • Modified ngtcp2_pkt_decode_path_challenge_frame and ngtcp2_pkt_decode_path_response_frame to copy data into the data member of ngtcp2_path_challenge_data.
    • Modified ngtcp2_pkt_encode_path_challenge_frame and ngtcp2_pkt_encode_path_response_frame to copy data from the data member of ngtcp2_path_challenge_data.
  • lib/ngtcp2_pkt.h
    • Updated ngtcp2_path_challenge and ngtcp2_path_response structs to embed ngtcp2_path_challenge_data.
  • lib/ngtcp2_pv.c
    • Included ngtcp2_str.h for memory comparison.
    • Modified ngtcp2_pv_entry_init to accept ngtcp2_path_challenge_data and initialize the struct directly.
    • Modified ngtcp2_pv_add_entry to accept ngtcp2_path_challenge_data by reference.
    • Modified ngtcp2_pv_validate to accept ngtcp2_path_challenge_data by reference and use ngtcp2_cmemeq for comparison.
  • lib/ngtcp2_pv.h
    • Updated ngtcp2_pv_entry struct to embed ngtcp2_path_challenge_data.
    • Modified ngtcp2_pv_entry_init, ngtcp2_pv_add_entry, and ngtcp2_pv_validate function signatures to use ngtcp2_path_challenge_data.
  • lib/ngtcp2_qlog.c
    • Updated write_path_challenge_frame and write_path_response_frame to access frame data through the data member of ngtcp2_path_challenge_data.
  • tests/ngtcp2_callbacks_test.c
    • Added get_path_challenge_data2 test function.
    • Updated test_ngtcp2_callbacks_convert_to_latest and test_ngtcp2_callbacks_convert_to_old to include get_path_challenge_data2 in callback checks.
  • tests/ngtcp2_conn_test.c
    • Modified get_path_challenge_data test function to accept and initialize ngtcp2_path_challenge_data.
    • Updated server_default_callbacks and client_default_callbacks to assign get_path_challenge_data to get_path_challenge_data2.
    • Adjusted various test cases to initialize PATH_RESPONSE and PATH_CHALLENGE frames using the new struct literal syntax and ngtcp2_path_challenge_data.
  • tests/ngtcp2_log_test.c
    • Updated test cases for PATH_CHALLENGE and PATH_RESPONSE frames to use the new struct literal syntax for ngtcp2_path_challenge_data.
  • tests/ngtcp2_pkt_test.c
    • Updated test cases for encoding and decoding PATH_CHALLENGE and PATH_RESPONSE frames to use the new struct literal syntax and ngtcp2_path_challenge_data.
  • tests/ngtcp2_pv_test.c
    • Modified data variable type to ngtcp2_path_challenge_data in test_ngtcp2_pv_add_entry and test_ngtcp2_pv_validate.
    • Updated calls to ngtcp2_pv_add_entry and ngtcp2_pv_validate to pass ngtcp2_path_challenge_data by reference.
    • Adjusted data initialization in test_ngtcp2_pv_validate to use ngtcp2_path_challenge_data struct literals.
  • tests/ngtcp2_qlog_test.c
    • Updated test cases for qlog frame writing to use the new struct literal syntax for ngtcp2_path_challenge_data.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces ngtcp2_path_challenge_data to improve type safety for path challenge data, which is a significant improvement over using raw byte pointers. The changes are consistently applied throughout the library, crypto backends, examples, and tests. The adoption of modern C features like compound literals for struct initialization enhances code readability and maintainability. Backward compatibility for the deprecated callback is also correctly handled. I've found one minor typo in a documentation comment that should be addressed.

This commit introduces struct ngtcp2_path_challenge_data just like
ngtcp2_stateless_reset_token in earlier commits.

This commit deprecates ngtcp2_get_path_challenge_data.  It adds
ngtcp2_get_path_challenge_data2 as a replacement.

This commit deprecates ngtcp2_crypto_get_path_challenge_data_cb.  It
adds ngtcp2_crypto_get_path_challenge_data2_cb as a replacement.
@tatsuhiro-t tatsuhiro-t force-pushed the struct-path-challenge-data branch from 0e7a11a to 7934f78 Compare March 1, 2026 09:04
@tatsuhiro-t tatsuhiro-t merged commit 47ac399 into main Mar 1, 2026
73 checks passed
@tatsuhiro-t tatsuhiro-t deleted the struct-path-challenge-data branch March 1, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant