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 @@ -1515,3 +1515,31 @@ void tlshd_tags_config_shutdown(void)
15151515 tlshd_tags_filter_hash_destroy ();
15161516 tlshd_tags_filter_type_hash_destroy ();
15171517}
1518+
1519+ /**
1520+ * tlshd_tags_for_each_matched - Call @cb for each matched tag
1521+ * @cb: callback function
1522+ * @data: data to be passed to each callback
1523+ *
1524+ * Returns zero if the callback returned only zeroes. Otherwise, the
1525+ * first non-zero callback return stops the loop and returns that
1526+ * non-zero value.
1527+ */
1528+ int tlshd_tags_for_each_matched (int (* cb )(const char * name , void * data ),
1529+ void * data )
1530+ {
1531+ GHashTableIter iter ;
1532+ gpointer key , value ;
1533+
1534+ if (!tlshd_tags_tag_hash )
1535+ return 0 ;
1536+
1537+ g_hash_table_iter_init (& iter , tlshd_tags_tag_hash );
1538+ while (g_hash_table_iter_next (& iter , & key , & value )) {
1539+ struct tlshd_tags_tag * tag = (struct tlshd_tags_tag * )value ;
1540+
1541+ if (tag -> ta_matched )
1542+ (cb )(tag -> ta_name , data );
1543+ }
1544+ return 0 ;
1545+ }
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 void 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