Skip to content

Commit

Permalink
Reorganize imports in common and address modules
Browse files Browse the repository at this point in the history
Was throwing a compilation warning in FreeBSD.
  • Loading branch information
ydahhrk committed Oct 19, 2021
1 parent 4ff31f4 commit 43a5ebe
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
22 changes: 16 additions & 6 deletions src/address.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include "address.h"

#include <string.h>
#include <errno.h>
#include <arpa/inet.h> /* inet_ntop */
#include <sys/types.h> /* AF_INET, AF_INET6 (needed in OpenBSD) */
#include <sys/socket.h> /* AF_INET, AF_INET6 (needed in OpenBSD) */
#include "common.h"
#include <stdlib.h> /* strtoul() */
#include <string.h> /* memset(), memcpy() */
#include <arpa/inet.h> /* inet_ntop(), htonl() */

#include "log.h"
#include "thread_var.h"

Expand Down Expand Up @@ -515,6 +513,18 @@ ipv6_covered(struct in6_addr *f_addr, uint8_t f_len, struct in6_addr *son_addr)
return true;
}

char const *
addr2str4(struct in_addr const *addr, char *buffer)
{
return inet_ntop(AF_INET, addr, buffer, INET_ADDRSTRLEN);
}

char const *
addr2str6(struct in6_addr const *addr, char *buffer)
{
return inet_ntop(AF_INET6, addr, buffer, INET6_ADDRSTRLEN);
}

/**
* buffer must length INET6_ADDRSTRLEN.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ int ipv6_prefix_validate(struct ipv6_prefix *);
bool ipv4_covered(struct in_addr *, uint8_t, struct in_addr *);
bool ipv6_covered(struct in6_addr *, uint8_t, struct in6_addr *);

char const *addr2str4(struct in_addr const *, char *);
char const *addr2str6(struct in6_addr const *, char *);
void sockaddr2str(struct sockaddr_storage *, char *buffer);

#endif /* SRC_ADDRESS_H_ */
29 changes: 8 additions & 21 deletions src/common.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#include "common.h"

#include <errno.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h> /* AF_INET, AF_INET6 (needed in OpenBSD) */
#include <sys/socket.h> /* AF_INET, AF_INET6 (needed in OpenBSD) */
#include <sys/stat.h>
#include <dirent.h> /* readdir(), closedir() */
#include <limits.h> /* realpath() */
#include <stdlib.h> /* malloc(), free(), realloc(), realpath() */
#include <stdio.h> /* remove() */
#include <string.h> /* strdup(), strrchr(), strcmp(), strcat(), etc */
#include <unistd.h> /* stat(), rmdir() */
#include <sys/stat.h> /* stat(), mkdir() */
#include <sys/types.h> /* stat(), closedir(), mkdir() */

#include "config.h"
#include "log.h"
Expand Down Expand Up @@ -198,18 +197,6 @@ valid_file_or_dir(char const *location, bool check_file, bool check_dir,
return result;
}

char const *
addr2str4(struct in_addr const *addr, char *buffer)
{
return inet_ntop(AF_INET, addr, buffer, INET_ADDRSTRLEN);
}

char const *
addr2str6(struct in6_addr const *addr, char *buffer)
{
return inet_ntop(AF_INET6, addr, buffer, INET6_ADDRSTRLEN);
}

static int
dir_exists(char const *path, bool *result)
{
Expand Down
4 changes: 0 additions & 4 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <pthread.h>
#include <stdbool.h>
#include <time.h>
#include <netinet/in.h>

/* "I think that this is not supposed to be implemented." */
#define ENOTSUPPORTED 3172
Expand Down Expand Up @@ -54,9 +53,6 @@ int process_file_or_dir(char const *, char const *, bool, process_file_cb,
typedef int (*pr_errno_cb)(int, const char *, ...);
bool valid_file_or_dir(char const *, bool, bool, pr_errno_cb);

char const *addr2str4(struct in_addr const *, char *);
char const *addr2str6(struct in6_addr const *, char *);

int create_dir_recursive(char const *);
int delete_dir_recursive_bottom_up(char const *);

Expand Down
3 changes: 0 additions & 3 deletions src/object/certificate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,19 +1839,16 @@ static int
get_certificate_type(X509 *cert, bool is_ta, enum cert_type *result)
{
if (is_ta) {
/* Note: It looks weird if we log the type here. */
*result = TA;
return 0;
}

if (X509_check_ca(cert) == 1) {
pr_val_debug("Type: CA");
*result = CA;
return 0;
}

if (has_bgpsec_router_eku(cert)) {
pr_val_debug("Type: BGPsec EE");
*result = BGPSEC;
return 0;
}
Expand Down

0 comments on commit 43a5ebe

Please sign in to comment.