Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
rpki-client: tiny tweaks
To:
tech@openbsd.org
Date:
Wed, 21 Feb 2024 12:03:49 +0100

Download raw body.

Thread
ip_addr_cmp() and tak_read() never existed. Fix indent, group the logx
and the time functions together (in main.c get_current_time() was
between entity_* functions, which makes no sense), move the X509_TIME_*
defines to main.c since they aren't used elsewhere and explain the magic
numbers.

This shouldn't conflict with job's spl work.

Index: extern.h
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v
diff -u -p -r1.204 extern.h
--- extern.h	16 Feb 2024 05:18:29 -0000	1.204
+++ extern.h	21 Feb 2024 10:55:26 -0000
@@ -652,7 +652,6 @@ void		 takey_free(struct takey *);
 void		 tak_free(struct tak *);
 struct tak	*tak_parse(X509 **, const char *, int, const unsigned char *,
 		    size_t);
-struct tak	*tak_read(struct ibuf *);
 
 void		 aspa_buffer(struct ibuf *, const struct aspa *);
 void		 aspa_free(struct aspa *);
@@ -708,7 +707,6 @@ int		 ip_addr_parse(const ASN1_BIT_STRIN
 			enum afi, const char *, struct ip_addr *);
 void		 ip_addr_print(const struct ip_addr *, enum afi, char *,
 			size_t);
-int		 ip_addr_cmp(const struct ip_addr *, const struct ip_addr *);
 int		 ip_addr_check_overlap(const struct cert_ip *,
 			const char *, const struct cert_ip *, size_t, int);
 int		 ip_addr_check_covered(enum afi, const unsigned char *,
@@ -729,9 +727,9 @@ int		 sbgp_parse_ipaddrblk(const char *,
 
 int		 as_id_parse(const ASN1_INTEGER *, uint32_t *);
 int		 as_check_overlap(const struct cert_as *, const char *,
-			const struct cert_as *, size_t, int);
+		    const struct cert_as *, size_t, int);
 int		 as_check_covered(uint32_t, uint32_t,
-			const struct cert_as *, size_t);
+		    const struct cert_as *, size_t);
 void		 as_warn(const char *, const char *, const struct cert_as *);
 
 int		 sbgp_as_id(const char *, struct cert_as *, size_t *,
@@ -904,9 +902,11 @@ int		 output_json(FILE *, struct vrp_tre
 int		 output_ometric(FILE *, struct vrp_tree *, struct brk_tree *,
 		    struct vap_tree *, struct stats *);
 
-void		logx(const char *fmt, ...)
+void		 logx(const char *fmt, ...)
 		    __attribute__((format(printf, 1, 2)));
-time_t		getmonotime(void);
+time_t		 getmonotime(void);
+extern time_t	 get_current_time(void);
+
 
 int	mkpath(const char *);
 int	mkpathat(int, const char *);
@@ -957,13 +957,5 @@ int	mkpathat(int, const char *);
 
 /* Maximum number of delegated hosting locations (repositories) for each TAL. */
 #define MAX_REPO_PER_TAL	1000
-
-/*
- * Time - Evaluation time is used as the current time if it is
- * larger than X509_TIME_MIN, otherwise the system time is used.
- */
-#define X509_TIME_MAX 253402300799LL
-#define X509_TIME_MIN -62167219200LL
-extern time_t  get_current_time(void);
 
 #endif /* ! EXTERN_H */
Index: main.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v
diff -u -p -r1.249 main.c
--- main.c	16 Feb 2024 11:55:42 -0000	1.249
+++ main.c	21 Feb 2024 10:53:58 -0000
@@ -74,6 +74,11 @@ int	rrdpon = 1;
 int	repo_timeout;
 time_t	deadline;
 
+/* 9999-12-31 23:59:59 UTC */
+#define X509_TIME_MAX 253402300799LL
+/* 0000-01-01 00:00:00 UTC */
+#define X509_TIME_MIN -62167219200LL
+
 int64_t  evaluation_time = X509_TIME_MIN;
 
 struct stats	 stats;
@@ -113,6 +118,18 @@ getmonotime(void)
 	return (ts.tv_sec);
 }
 
+/*
+ * Time - Evaluation time is used as the current time if it is
+ * larger than X509_TIME_MIN, otherwise the system time is used.
+ */
+time_t
+get_current_time(void)
+{
+	if (evaluation_time > X509_TIME_MIN)
+		return (time_t)evaluation_time;
+	return time(NULL);
+}
+
 void
 entity_free(struct entity *ent)
 {
@@ -124,14 +141,6 @@ entity_free(struct entity *ent)
 	free(ent->mftaki);
 	free(ent->data);
 	free(ent);
-}
-
-time_t
-get_current_time(void)
-{
-	if (evaluation_time > X509_TIME_MIN)
-		return (time_t)evaluation_time;
-	return time(NULL);
 }
 
 /*