Skip to content

Commit d5aee75

Browse files
romanmichalvasko
authored andcommitted
session_p UPDATE add cert exp notif structs
1 parent 646a3f1 commit d5aee75

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

src/session_p.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "compat.h"
2929
#include "config.h"
3030
#include "session_client.h"
31+
#include "session_server.h"
3132
#include "session_server_ch.h"
3233
#include "session_wrapper.h"
3334

@@ -388,6 +389,70 @@ struct nc_client_context {
388389
#endif /* NC_ENABLED_SSH_TLS */
389390
};
390391

392+
#ifdef NC_ENABLED_SSH_TLS
393+
394+
/**
395+
* @brief Stores time information used for creating certificate expiration intervals.
396+
*/
397+
struct nc_cert_exp_time {
398+
int months;
399+
int weeks;
400+
int days;
401+
int hours;
402+
};
403+
404+
/**
405+
* @brief Stores information about a certificate expiration notification.
406+
*/
407+
struct nc_cert_expiration {
408+
time_t *starts_of_intervals; /**< Array of the starting times of the certificate expiration notification intervals. */
409+
int current_interval; /**< Index of the current interval. */
410+
411+
time_t expiration_time; /**< Time of the certificate expiration. */
412+
time_t notif_time; /**< Time of the next notification. */
413+
414+
char *xpath; /**< XPath to the certificate. */
415+
};
416+
417+
/**
418+
* @brief Certificate expiration notification thread data.
419+
*/
420+
struct nc_cert_exp_notif_thread_arg {
421+
nc_cert_exp_notif_clb clb; /**< Callback called when a certificate expiration notification is ready to be sent. */
422+
void *clb_data; /**< Data passed to the callback. */
423+
void (*clb_free_data)(void *); /**< Callback to free the user data. */
424+
};
425+
426+
/**
427+
* @brief Auxiliary structure used for creating the XPaths to the certificates.
428+
*/
429+
struct nc_cert_path_aux {
430+
const char *ch_client_name;
431+
const char *endpt_name;
432+
const char *ca_cert_name;
433+
const char *ee_cert_name;
434+
const char *ks_askey_name;
435+
const char *ks_cert_name;
436+
const char *ts_cbag_name;
437+
const char *ts_cert_name;
438+
};
439+
440+
/**
441+
* @brief Update the values of the nc_cert_path_aux members.
442+
*/
443+
#define NC_CERT_EXP_UPDATE_CERT_PATH(cp, ch_client, endpt, ca_cert, \
444+
ee_cert, ks_askey, ks_cert, ts_cbag, ts_cert) \
445+
(cp)->ch_client_name = (ch_client); \
446+
(cp)->endpt_name = (endpt); \
447+
(cp)->ca_cert_name = (ca_cert); \
448+
(cp)->ee_cert_name = (ee_cert); \
449+
(cp)->ks_askey_name = (ks_askey); \
450+
(cp)->ks_cert_name = (ks_cert); \
451+
(cp)->ts_cbag_name = (ts_cbag); \
452+
(cp)->ts_cert_name = (ts_cert)
453+
454+
#endif /* NC_ENABLED_SSH_TLS */
455+
391456
/**
392457
* @brief Call Home client thread data.
393458
*/
@@ -518,6 +583,22 @@ struct nc_server_opts {
518583
/* Atomic IDs */
519584
ATOMIC_T new_session_id;
520585
ATOMIC_T new_client_id;
586+
587+
#ifdef NC_ENABLED_SSH_TLS
588+
pthread_t cert_exp_notif_thread_tid; /**< Thread ID of the certificate expiration notification thread. */
589+
int cert_exp_notif_thread_running; /**< Flag representing the runningness of the cert exp notification thread. */
590+
pthread_mutex_t cert_exp_notif_thread_lock; /**< Certificate expiration notification thread's data and cond lock. */
591+
pthread_cond_t cert_exp_notif_thread_cond; /**< Condition for the certificate expiration notification thread. */
592+
593+
/**
594+
* @brief Intervals for certificate expiration notifications.
595+
*/
596+
struct nc_interval {
597+
struct nc_cert_exp_time anchor; /**< Lower bound of the given interval. */
598+
struct nc_cert_exp_time period; /**< Period of the given interval. */
599+
} *intervals;
600+
int interval_count; /**< Number of intervals. */
601+
#endif
521602
};
522603

523604
/**

0 commit comments

Comments
 (0)