From: German Service Network Date: Sun, 11 Jan 2026 09:19:26 +0000 (+0100) Subject: Move the most function declarations from fping.c to fping.h X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec3d50ba6aac6c9f5204772376584ee3e551e991;p=fping.git Move the most function declarations from fping.c to fping.h --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 84129eb..6d5743a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Next recvmsg with MSG_DONTWAIT instead (#449) - Improved compatibility with NetBSD (#452, thanks @auerswal) - Consistent variable names for command-line options (#453, thanks @gsnw-sebast) +- Move the most function declarations from fping.c to fping.h (#454, thanks @gsnw-sebast) - Avoid crash with option `-0` (#457, thanks @auerswal) fping 5.5 (2025-12-31) diff --git a/src/fping.c b/src/fping.c index 064da20..3623ce0 100644 --- a/src/fping.c +++ b/src/fping.c @@ -458,53 +458,6 @@ unsigned int fwmark = 0; char *filename = NULL; /* file containing hosts to ping */ /*** forward declarations ***/ - -void add_name(char *name); -void add_addr(char *name, char *host, struct sockaddr *ipaddr, socklen_t ipaddr_len); -char *na_cat(char *name, struct in_addr ipaddr); -void crash_and_burn(char *message); -void errno_crash_and_burn(char *message); -char *get_host_by_address(struct in_addr in); -int send_ping(HOST_ENTRY *h, int index); -void usage(int); -int wait_for_reply(int64_t); -void print_recv(HOST_ENTRY *h, int64_t recv_time, int result, int this_count, int64_t this_reply, int avg); -void print_timeout(HOST_ENTRY *h, int ping_index); -void print_recv_ext(IP_HEADER_RESULT *ip_header_res, int64_t recv_time, int64_t this_reply); -void print_recv_ext_json(IP_HEADER_RESULT *ip_header_res, int64_t recv_time, int64_t this_reply); -void print_per_system_stats(void); -void print_per_system_stats_json(void); -void print_per_system_splits(void); -void print_per_system_splits_json(void); -void stats_reset_interval(HOST_ENTRY *h); -void print_netdata(void); -void print_global_stats(void); -void print_global_stats_json(void); -void main_loop(); -void signal_handler(int); -void finish(); -const char *sprint_tm(int64_t t); -void ev_enqueue(struct event_queue *queue, struct event *event); -struct event *ev_dequeue(struct event_queue *queue); -void ev_remove(struct event_queue *queue, struct event *event); -void add_cidr(char *); -void add_cidr_ipv4(unsigned long, unsigned long); -void add_range(char *, char *); -void add_addr_range_ipv4(unsigned long, unsigned long); -#ifdef IPV6 -uint64_t be_octets_to_uint64(uint8_t*); -void uint64_to_be_octets(uint64_t, uint8_t*); -void add_cidr_ipv6(uint64_t, uint64_t, unsigned long, const char *); -void add_addr_range_ipv6(uint64_t, uint64_t, uint64_t, uint64_t, const char *); -#endif -void print_warning(char *fmt, ...); -int addr_cmp(struct sockaddr *a, struct sockaddr *b); -void host_add_ping_event(HOST_ENTRY *h, int index, int64_t ev_time); -void host_add_timeout_event(HOST_ENTRY *h, int index, int64_t ev_time); -struct event *host_get_timeout_event(HOST_ENTRY *h, int index); -void stats_add(HOST_ENTRY *h, int index, int success, int64_t latency); -void update_current_time(); -void print_timestamp_format(int64_t current_time_ns, int timestamp_format); static uint32_t ms_since_midnight_utc(int64_t time_val); /************************************************************ diff --git a/src/fping.h b/src/fping.h index ab7c6c9..419b56e 100644 --- a/src/fping.h +++ b/src/fping.h @@ -3,6 +3,7 @@ #define __APPLE_USE_RFC_3542 1 +#include #include #include #include @@ -19,10 +20,59 @@ extern int opt_debug_trace_on; /* fping.c */ +typedef struct host_entry HOST_ENTRY; +struct event; +struct event_queue; +typedef struct ip_header_result IP_HEADER_RESULT; +extern int opt_random_data_on; + +void add_name(char *name); +void add_addr(char *name, char *host, struct sockaddr *ipaddr, socklen_t ipaddr_len); +char *na_cat(char *name, struct in_addr ipaddr); +char *get_host_by_address(struct in_addr in); +int send_ping(HOST_ENTRY *h, int index); +void usage(int); +int wait_for_reply(int64_t); +void print_recv(HOST_ENTRY *h, int64_t recv_time, int result, int this_count, int64_t this_reply, int avg); +void print_timeout(HOST_ENTRY *h, int ping_index); +void print_recv_ext(IP_HEADER_RESULT *ip_header_res, int64_t recv_time, int64_t this_reply); +void print_recv_ext_json(IP_HEADER_RESULT *ip_header_res, int64_t recv_time, int64_t this_reply); +void print_per_system_stats(void); +void print_per_system_stats_json(void); +void print_per_system_splits(void); +void print_per_system_splits_json(void); +void stats_reset_interval(HOST_ENTRY *h); +void print_netdata(void); +void print_global_stats(void); +void print_global_stats_json(void); +void main_loop(); +void signal_handler(int); +void finish(); +const char *sprint_tm(int64_t t); +void ev_enqueue(struct event_queue *queue, struct event *event); +struct event *ev_dequeue(struct event_queue *queue); +void ev_remove(struct event_queue *queue, struct event *event); +void add_cidr(char *); +void add_cidr_ipv4(unsigned long, unsigned long); +void add_range(char *, char *); +void add_addr_range_ipv4(unsigned long, unsigned long); +#ifdef IPV6 +uint64_t be_octets_to_uint64(uint8_t*); +void uint64_to_be_octets(uint64_t, uint8_t*); +void add_cidr_ipv6(uint64_t, uint64_t, unsigned long, const char *); +void add_addr_range_ipv6(uint64_t, uint64_t, uint64_t, uint64_t, const char *); +#endif +void print_warning(char *fmt, ...); +int addr_cmp(struct sockaddr *a, struct sockaddr *b); +void host_add_ping_event(HOST_ENTRY *h, int index, int64_t ev_time); +void host_add_timeout_event(HOST_ENTRY *h, int index, int64_t ev_time); +struct event *host_get_timeout_event(HOST_ENTRY *h, int index); +void stats_add(HOST_ENTRY *h, int index, int success, int64_t latency); +void update_current_time(); +void print_timestamp_format(int64_t current_time_ns, int timestamp_format); void crash_and_burn( char *message ); void errno_crash_and_burn( char *message ); int in_cksum( unsigned short *p, int n ); -extern int opt_random_data_on; /* socket.c */ int open_ping_socket_ipv4(int *socktype);