-Add missing getters at configuration impersonator.
-Create a common function to print IPv4 and IPv6 addresses, the function already existed but it was created multiple times at distinct sources.
#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 "log.h"
#include "thread_var.h"
return check_encoding6(result);
}
-static char const *
-addr2str4(struct in_addr *addr, char *buffer)
-{
- return inet_ntop(AF_INET, addr, buffer, INET_ADDRSTRLEN);
-}
-
-static char const *
-addr2str6(struct in6_addr *addr, char *buffer)
-{
- return inet_ntop(AF_INET6, addr, buffer, INET6_ADDRSTRLEN);
-}
-
static int
str2addr4(const char *addr, struct in_addr *dst)
{
#include <dirent.h>
#include <stdlib.h>
#include <string.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 "log.h"
return process_dir_files(location, file_ext, cb, arg);
}
+
+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);
+}
#include <pthread.h>
#include <semaphore.h>
+#include <arpa/inet.h>
/* "I think that this is not supposed to be implemented." */
#define ENOTSUPPORTED 3172
typedef int (*process_file_cb)(char const *, void *);
int process_file_or_dir(char const *, char const *, process_file_cb, void *);
+char const *addr2str4(struct in_addr const *, char *);
+char const *addr2str6(struct in6_addr const *, char *);
+
#endif /* SRC_RTR_COMMON_H_ */
#include "output_printer.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 "common.h"
#include "config.h"
#include "file.h"
#include "log.h"
char addr_buf[INET6_ADDRSTRLEN];
-static char const *
-strv4addr(struct in_addr const *addr)
-{
- return inet_ntop(AF_INET, addr, addr_buf, INET6_ADDRSTRLEN);
-}
-
-static char const *
-strv6addr(struct in6_addr const *addr)
-{
- return inet_ntop(AF_INET6, addr, addr_buf, INET6_ADDRSTRLEN);
-}
-
static int
load_output_file(char const *output, FILE **result, bool *fopen)
{
switch(vrp->addr_fam) {
case AF_INET:
fprintf(out, "AS%u,%s/%u,%u\n", vrp->asn,
- strv4addr(&vrp->prefix.v4), vrp->prefix_length,
+ addr2str4(&vrp->prefix.v4, addr_buf), vrp->prefix_length,
vrp->max_prefix_length);
break;
case AF_INET6:
fprintf(out, "AS%u,%s/%u,%u\n", vrp->asn,
- strv6addr(&vrp->prefix.v6), vrp->prefix_length,
+ addr2str6(&vrp->prefix.v6, addr_buf), vrp->prefix_length,
vrp->max_prefix_length);
break;
default:
#include <stdlib.h>
#include <string.h>
#include <unistd.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 <arpa/inet.h> /* INET_ADDRSTRLEN */
#include "clients.h"
+#include "common.h"
#include "config.h"
#include "log.h"
#include "rtr/pdu_serializer.h"
pr_debug_prefix4(struct ipv4_prefix_pdu *pdu)
{
char buffer[INET_ADDRSTRLEN];
- char const *addr_str;
- addr_str = inet_ntop(AF_INET, &pdu->ipv4_prefix, buffer,
- INET_ADDRSTRLEN);
-
- pr_debug("Encoded prefix %s/%u into a PDU.", addr_str,
- pdu->prefix_length);
+ pr_debug("Encoded prefix %s/%u into a PDU.",
+ addr2str4(&pdu->ipv4_prefix, buffer), pdu->prefix_length);
}
static int
pr_debug_prefix6(struct ipv6_prefix_pdu *pdu)
{
char buffer[INET6_ADDRSTRLEN];
- char const *addr_str;
-
- addr_str = inet_ntop(AF_INET6, &pdu->ipv6_prefix, buffer,
- INET6_ADDRSTRLEN);
- pr_debug("Encoded prefix %s/%u into a PDU.", addr_str,
- pdu->prefix_length);
+ pr_debug("Encoded prefix %s/%u into a PDU.",
+ addr2str6(&pdu->ipv6_prefix, buffer), pdu->prefix_length);
}
static int
#include <string.h>
#include <time.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 "crypto/base64.h"
#include "data_structure/array_list.h"
#include "object/router_key.h"
+#include "common.h"
struct slurm_prefix_ctx {
struct slurm_prefix element;
db->loaded_date_set = true;
}
-static char const *
-strv4addr(struct in_addr const *addr)
-{
- return inet_ntop(AF_INET, addr, addr_buf, INET6_ADDRSTRLEN);
-}
-
-static char const *
-strv6addr(struct in6_addr const *addr)
-{
- return inet_ntop(AF_INET6, addr, addr_buf, INET6_ADDRSTRLEN);
-}
-
static int
print_prefix_data(struct slurm_prefix *prefix, void *arg)
{
switch(prefix->vrp.addr_fam) {
case AF_INET:
pr_info("%s Prefix: %s/%u", pad,
- strv4addr(&prefix->vrp.prefix.v4),
+ addr2str4(&prefix->vrp.prefix.v4, addr_buf),
prefix->vrp.prefix_length);
break;
case AF_INET6:
pr_info("%s Prefix: %s/%u", pad,
- strv6addr(&prefix->vrp.prefix.v6),
+ addr2str6(&prefix->vrp.prefix.v6, addr_buf),
prefix->vrp.prefix_length);
break;
default:
#include <stdlib.h>
#include "address.c"
+#include "common.c"
#include "log.c"
#include "impersonator.c"
#include "impersonator.c"
static int
-handle_foreach(struct client const *client, void *arg)
+handle_foreach(struct client *client, void *arg)
{
unsigned int *state = arg;
return NULL;
}
+uint8_t
+config_get_log_level(void)
+{
+ return 3; /* LOG_ERR */
+}
+
+enum log_output
+config_get_log_output(void)
+{
+ return CONSOLE;
+}
+
+unsigned int
+config_get_asn1_decode_max_stack(void)
+{
+ return 4096;
+}
+
enum incidence_action
incidence_get_action(enum incidence_id id)
{
#include <stdlib.h>
#include "address.c"
+#include "common.c"
#include "log.c"
#include "impersonator.c"
#include "object/router_key.c"
#include <stdio.h>
#include <unistd.h>
+#include "common.c"
#include "log.c"
#include "impersonator.c"
#include "rtr/stream.c"