File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -574,6 +574,25 @@ static int tlshd_genl_put_remote_peerids(struct nl_msg *msg,
574574 return 0 ;
575575}
576576
577+ static int tlshd_genl_put_tag (const char * name ,
578+ __attribute__ ((unused )) void * data )
579+ {
580+ struct nl_msg * msg = data ;
581+ int err ;
582+
583+ err = nla_put_string (msg , HANDSHAKE_A_DONE_TAG , name );
584+ if (err < 0 ) {
585+ tlshd_log_nl_error ("nla_put tag" , err );
586+ return -1 ;
587+ }
588+ return 0 ;
589+ }
590+
591+ static int tlshd_genl_put_tag_list (struct nl_msg * msg )
592+ {
593+ return tlshd_tags_for_each_matched (tlshd_genl_put_tag , (void * )msg );
594+ }
595+
577596/**
578597 * @brief Indicate handshake has completed successfully
579598 * @param[in] parms Buffer filled in with parameters
@@ -630,6 +649,12 @@ void tlshd_genl_done(struct tlshd_handshake_parms *parms)
630649 if (err < 0 )
631650 goto out_free ;
632651
652+ err = tlshd_genl_put_tag_list (msg );
653+ if (err < 0 ) {
654+ tlshd_log_nl_error ("nla_put tag list" , err );
655+ goto out_free ;
656+ }
657+
633658sendit :
634659 if (tlshd_delay_done ) {
635660 /* Undocumented tlshd.conf parameter:
Original file line number Diff line number Diff line change @@ -2012,4 +2012,37 @@ void tlshd_tags_config_shutdown(void)
20122012 tlshd_tags_name_destroy ();
20132013}
20142014
2015+
20152016///@}
2017+
2018+ /**
2019+ * @brief Invoke "cb" for each global tag marked as a match
2020+ * @param[in] cb Function to be called for each matched tag
2021+ * @param[in] data Context to be passed on each call to "cb"
2022+ *
2023+ * @returns zero if the callback returned only zeroes; otherwise, the
2024+ * first non-zero callback return stops the loop and returns that
2025+ * non-zero value.
2026+ */
2027+ int tlshd_tags_for_each_matched (int (* cb )(const char * name , void * data ),
2028+ void * data )
2029+ {
2030+ GHashTableIter iter ;
2031+ gpointer key , value ;
2032+
2033+ if (!tlshd_tags_tag_hash )
2034+ return 0 ;
2035+
2036+ g_hash_table_iter_init (& iter , tlshd_tags_tag_hash );
2037+ while (g_hash_table_iter_next (& iter , & key , & value )) {
2038+ struct tlshd_tags_tag * tag = (struct tlshd_tags_tag * )value ;
2039+ int ret ;
2040+
2041+ if (tag -> ta_matched ) {
2042+ ret = (cb )(tag -> ta_name , data );
2043+ if (ret )
2044+ return ret ;
2045+ }
2046+ }
2047+ return 0 ;
2048+ }
Original file line number Diff line number Diff line change @@ -138,6 +138,8 @@ extern void tlshd_quic_serverhello_handshake(struct tlshd_handshake_parms *parms
138138extern bool tlshd_tags_config_init (const char * tagsdir );
139139extern void tlshd_tags_config_shutdown (void );
140140extern void tlshd_tags_match_session (gnutls_session_t session );
141+ extern int tlshd_tags_for_each_matched (int (* cb )(const char * name , void * data ),
142+ void * data );
141143
142144#ifdef HAVE_GNUTLS_QUIC
143145#include "quic.h"
You can’t perform that action at this time.
0 commit comments