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 @@ -1241,3 +1241,41 @@ void tlsdh_tags_x509_match_session(gnutls_session_t session)
12411241 tlshd_tags_x509_match_cb , (gpointer )& peercert );
12421242 gnutls_x509_crt_deinit (peercert );
12431243}
1244+
1245+ struct tlshd_tags_matched_args {
1246+ int (* ma_cb )(const char * name , void * data );
1247+ void * ma_data ;
1248+ };
1249+
1250+ static void tlshd_tags_matched_cb (gpointer data , gpointer user_data )
1251+ {
1252+ struct tlshd_tags_tag * tag = (struct tlshd_tags_tag * )data ;
1253+ struct tlshd_tags_matched_args * args =
1254+ (struct tlshd_tags_matched_args * )user_data ;
1255+
1256+ if (tag -> ta_matched )
1257+ (args -> ma_cb )(tag -> ta_name , args -> ma_data );
1258+ }
1259+
1260+ /**
1261+ * tlshd_for_each_matched_tag - Call @cb for all matched tags
1262+ * @cb: callback function
1263+ * @data: data to be passed to each callback
1264+ *
1265+ * Returns zero if the callback returned only zeroes. Otherwise, the
1266+ * first non-zero callback return stops the loop and returns that
1267+ * non-zero value.
1268+ */
1269+ int tlshd_for_each_matched_tag (int (* cb )(const char * name , void * data ),
1270+ void * data )
1271+ {
1272+ struct tlshd_tags_matched_args args = {
1273+ .ma_cb = cb ,
1274+ .ma_data = data ,
1275+ };
1276+
1277+ g_ptr_array_foreach (tlshd_tags_tag_all ,
1278+ tlshd_tags_matched_cb ,
1279+ (gpointer )& args );
1280+ return 0 ;
1281+ }
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