35#include "cmdhandler.h"
40#include "clientpipe.h"
41#include "longgetopt.h"
45static const char *module_str =
"rollover_list_cmd";
62 return strdup(
"waiting for ds-submit");
64 return strdup(
"waiting for ds-seen");
66 return strdup(
"waiting for ds-retract");
68 return strdup(
"waiting for ds-gone");
78 if (!t)
return strdup(
"No roll scheduled");
80 localtime_r(&t, &srtm);
81 strftime(ct, 26,
"%Y-%m-%d %H:%M:%S", &srtm);
86print_zone(
int sockfd,
const char* fmt,
const zone_db_t* zone)
93 char *tchange = map_keytime(zone, key);
110perform_rollover_list(
int sockfd,
const char *listed_zone,
116 const char* fmt =
"%-31s %-8s %-30s\n";
124 if (listed_zone && !zone) {
125 ods_log_error(
"[%s] zone '%s' not found", module_str, listed_zone);
126 client_printf(sockfd,
"zone '%s' not found\n", listed_zone);
130 if (!zone && !zonelist) {
131 ods_log_error(
"[%s] error enumerating zones", module_str);
132 client_printf(sockfd,
"error enumerating zones\n");
136 client_printf(sockfd,
"Keys:\n");
137 client_printf(sockfd, fmt,
"Zone:",
"Keytype:",
"Rollover expected:");
140 print_zone(sockfd, fmt, zone);
146 print_zone(sockfd, fmt, zone_walk);
155 client_printf(sockfd,
157 " [--zone <zone>] aka -z\n"
164 client_printf(sockfd,
165 "List the expected dates and times of upcoming rollovers. This can be used to get an idea of upcoming works.\n"
167 "zone name of the zone\n\n");
171run(cmdhandler_ctx_type* context,
int argc,
char* argv[])
173 int sockfd = context->sockfd;
174 struct longgetopt optctx;
175 int long_index = 0, opt = 0;
176 const char *zone = NULL;
179 static struct option long_options[] = {
180 {
"zone", required_argument, 0,
'z'},
184 for(opt = longgetopt(argc, argv,
"z:", long_options, &long_index, &optctx); opt != -1;
185 opt = longgetopt(argc, argv, NULL, long_options, &long_index, &optctx)) {
188 zone = optctx.optarg;
191 client_printf_err(sockfd,
"unknown arguments\n");
192 ods_log_error(
"[%s] unknown arguments for rollover list command", module_str);
196 return perform_rollover_list(sockfd, zone, dbconn);
200 "rollover list", &usage, &help, NULL, NULL, &run, NULL
db_connection_t * getconnectioncontext(cmdhandler_ctx_type *context)
const char * key_data_role_text(const key_data_t *key_data)
void key_data_list_free(key_data_list_t *key_data_list)
const key_data_t * key_data_list_next(key_data_list_t *key_data_list)
@ KEY_DATA_DS_AT_PARENT_SUBMITTED
@ KEY_DATA_DS_AT_PARENT_RETRACT
@ KEY_DATA_DS_AT_PARENT_SUBMIT
@ KEY_DATA_DS_AT_PARENT_RETRACTED
struct cmd_func_block rollover_list_funcblock
zone_list_db_t * zone_list_db_new_get(const db_connection_t *connection)
void zone_db_free(zone_db_t *zone)
const char * zone_db_name(const zone_db_t *zone)
unsigned int zone_db_next_ksk_roll(const zone_db_t *zone)
unsigned int zone_db_next_csk_roll(const zone_db_t *zone)
unsigned int zone_db_next_zsk_roll(const zone_db_t *zone)
zone_db_t * zone_db_new_get_by_name(const db_connection_t *connection, const char *name)
const zone_db_t * zone_list_db_next(zone_list_db_t *zone_list)
void zone_list_db_free(zone_list_db_t *zone_list)
key_data_list_t * zone_db_get_keys(const zone_db_t *zone)