File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed
Expand file tree Collapse file tree 3 files changed +65
-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_for_each_matched_tag (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 @@ -1229,3 +1229,41 @@ void tlsdh_tags_x509_match_session(gnutls_session_t session)
12291229 tlshd_tags_x509_match_cb , (gpointer )& peercert );
12301230 gnutls_x509_crt_deinit (peercert );
12311231}
1232+
1233+ struct tlshd_tags_matched_args {
1234+ int (* ma_cb )(const char * name , void * data );
1235+ void * ma_data ;
1236+ };
1237+
1238+ static void tlshd_tags_matched_cb (gpointer data , gpointer user_data )
1239+ {
1240+ struct tlshd_tags_tag * tag = (struct tlshd_tags_tag * )data ;
1241+ struct tlshd_tags_matched_args * args =
1242+ (struct tlshd_tags_matched_args * )user_data ;
1243+
1244+ if (tag -> ta_matched )
1245+ (args -> ma_cb )(tag -> ta_name , args -> ma_data );
1246+ }
1247+
1248+ /**
1249+ * tlshd_for_each_matched_tag - Call @cb for all matched tags
1250+ * @cb: callback function
1251+ * @data: data to be passed to each callback
1252+ *
1253+ * Returns zero if the callback returned only zeroes. Otherwise, the
1254+ * first non-zero callback return stops the loop and returns that
1255+ * non-zero value.
1256+ */
1257+ int tlshd_for_each_matched_tag (int (* cb )(const char * name , void * data ),
1258+ void * data )
1259+ {
1260+ struct tlshd_tags_matched_args args = {
1261+ .ma_cb = cb ,
1262+ .ma_data = data ,
1263+ };
1264+
1265+ g_ptr_array_foreach (tlshd_tags_tag_all ,
1266+ tlshd_tags_matched_cb ,
1267+ (gpointer )& args );
1268+ return 0 ;
1269+ }
Original file line number Diff line number Diff line change @@ -122,6 +122,8 @@ extern void tlshd_quic_serverhello_handshake(struct tlshd_handshake_parms *parms
122122/* tags.c */
123123extern void tlshd_tags_read_configuration (const char * tagsdir );
124124extern void tlsdh_tags_x509_match_session (gnutls_session_t session );
125+ extern int tlshd_for_each_matched_tag (int (* cb )(const char * name , void * data ),
126+ void * data );
125127extern void tlshd_tags_shutdown (void );
126128
127129#ifdef HAVE_GNUTLS_QUIC
You can’t perform that action at this time.
0 commit comments