File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -493,6 +493,25 @@ static int tlshd_genl_put_remote_peerids(struct nl_msg *msg,
493493 return 0 ;
494494}
495495
496+ static int tlshd_genl_put_tag (const char * name ,
497+ __attribute__ ((unused )) void * data )
498+ {
499+ struct nl_msg * msg = data ;
500+ int err ;
501+
502+ err = nla_put_string (msg , HANDSHAKE_A_DONE_TAG , name );
503+ if (err < 0 ) {
504+ tlshd_log_nl_error ("nla_put tag" , err );
505+ return -1 ;
506+ }
507+ return 0 ;
508+ }
509+
510+ static int tlshd_genl_put_tag_list (struct nl_msg * msg )
511+ {
512+ return tlshd_tags_for_each_matched (tlshd_genl_put_tag , (void * )msg );
513+ }
514+
496515/**
497516 * tlshd_genl_done - Indicate handshake has completed successfully
498517 * @parms: buffer filled in with parameters
@@ -550,6 +569,12 @@ void tlshd_genl_done(struct tlshd_handshake_parms *parms)
550569 if (err < 0 )
551570 goto out_free ;
552571
572+ err = tlshd_genl_put_tag_list (msg );
573+ if (err < 0 ) {
574+ tlshd_log_nl_error ("nla_put tag list" , err );
575+ goto out_free ;
576+ }
577+
553578sendit :
554579 if (tlshd_delay_done ) {
555580 /* Undocumented tlshd.conf parameter:
Original file line number Diff line number Diff line change @@ -1669,3 +1669,31 @@ void tlshd_tags_config_shutdown(void)
16691669 tlshd_tags_filter_type_hash_destroy ();
16701670 tlshd_tags_name_destroy ();
16711671}
1672+
1673+ /**
1674+ * tlshd_tags_for_each_matched - Call @cb for each matched tag
1675+ * @cb: callback function
1676+ * @data: data to be passed to each callback
1677+ *
1678+ * Returns zero if the callback returned only zeroes. Otherwise, the
1679+ * first non-zero callback return stops the loop and returns that
1680+ * non-zero value.
1681+ */
1682+ int tlshd_tags_for_each_matched (int (* cb )(const char * name , void * data ),
1683+ void * data )
1684+ {
1685+ GHashTableIter iter ;
1686+ gpointer key , value ;
1687+
1688+ if (!tlshd_tags_tag_hash )
1689+ return 0 ;
1690+
1691+ g_hash_table_iter_init (& iter , tlshd_tags_tag_hash );
1692+ while (g_hash_table_iter_next (& iter , & key , & value )) {
1693+ struct tlshd_tags_tag * tag = (struct tlshd_tags_tag * )value ;
1694+
1695+ if (tag -> ta_matched )
1696+ (cb )(tag -> ta_name , data );
1697+ }
1698+ return 0 ;
1699+ }
Original file line number Diff line number Diff line change @@ -123,6 +123,8 @@ extern void tlshd_quic_serverhello_handshake(struct tlshd_handshake_parms *parms
123123extern bool tlshd_tags_config_init (const char * tagsdir );
124124extern void tlshd_tags_config_shutdown (void );
125125extern void tlshd_tags_match_session (gnutls_session_t session );
126+ extern int tlshd_tags_for_each_matched (int (* cb )(const char * name , void * data ),
127+ void * data );
126128
127129#ifdef HAVE_GNUTLS_QUIC
128130#include <linux/quic.h>
You can’t perform that action at this time.
0 commit comments