return val;
}
-extern ATTRIBUTE_CONST size_t get_iiwidth_len(void) {
+ATTRIBUTE_CONST size_t get_iiwidth_len(void) {
return (sizeof(iiwidth) / sizeof((iiwidth)[0]));
}
-extern ATTRIBUTE_CONST int get_iiwidth(int ipinfo_no) {
+ATTRIBUTE_CONST int get_iiwidth(int ipinfo_no) {
static const int len = (sizeof(iiwidth) / sizeof((iiwidth)[0]));
if (ipinfo_no < len)
return iiwidth[ipinfo_no % len];
}
-extern char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr){
+char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr){
char *ipinfo = get_ipinfo(ctl, addr);
char fmt[8];
snprintf(fmt, sizeof(fmt), "%s%%-%ds", ctl->ipinfo_no?"":"AS", get_iiwidth(ctl->ipinfo_no));
return fmtinfo;
}
-extern int is_printii(struct mtr_ctl *ctl) {
+int is_printii(struct mtr_ctl *ctl) {
return ((ctl->ipinfo_no >= 0) && (ctl->ipinfo_no != ctl->ipinfo_max));
}
-extern void asn_open(struct mtr_ctl *ctl) {
+void asn_open(struct mtr_ctl *ctl) {
if (ctl->ipinfo_no >= 0) {
DEB_syslog(LOG_INFO, "hcreate(%d)", IIHASH_HI);
if (!(iihash = hcreate(IIHASH_HI)))
}
}
-extern void asn_close(struct mtr_ctl *ctl) {
+void asn_close(struct mtr_ctl *ctl) {
if ((ctl->ipinfo_no >= 0) && iihash) {
DEB_syslog(LOG_INFO, "hdestroy()");
hdestroy();
}
-extern int mtr_curses_keyaction(struct mtr_ctl *ctl)
+int mtr_curses_keyaction(struct mtr_ctl *ctl)
{
int c = getch();
int i = 0;
}
-extern void mtr_curses_redraw(struct mtr_ctl *ctl)
+void mtr_curses_redraw(struct mtr_ctl *ctl)
{
int maxx;
int startstat;
}
-extern void mtr_curses_open(struct mtr_ctl *ctl)
+void mtr_curses_open(struct mtr_ctl *ctl)
{
int bg_col = 0;
int i;
}
-extern void mtr_curses_close(void)
+void mtr_curses_close(void)
{
printw("\n");
endwin();
}
-extern void mtr_curses_clear(struct mtr_ctl *ctl)
+void mtr_curses_clear(struct mtr_ctl *ctl)
{
mtr_curses_close();
mtr_curses_open(ctl);
# define UNUSED_IF_NO_GTK ATTRIBUTE_UNUSED
#endif
-extern void display_detect(struct mtr_ctl *ctl, int *argc UNUSED_IF_NO_GTK,
+void display_detect(struct mtr_ctl *ctl, int *argc UNUSED_IF_NO_GTK,
char ***argv UNUSED_IF_NO_GTK)
{
ctl->DisplayMode = DEFAULT_DISPLAY;
}
-extern void display_open(struct mtr_ctl *ctl)
+void display_open(struct mtr_ctl *ctl)
{
switch(ctl->DisplayMode) {
}
-extern void display_close(struct mtr_ctl *ctl)
+void display_close(struct mtr_ctl *ctl)
{
time_t now;
}
-extern void display_redraw(struct mtr_ctl *ctl)
+void display_redraw(struct mtr_ctl *ctl)
{
switch(ctl->DisplayMode) {
}
-extern int display_keyaction(struct mtr_ctl *ctl)
+int display_keyaction(struct mtr_ctl *ctl)
{
switch(ctl->DisplayMode) {
#ifdef HAVE_CURSES
}
-extern void display_rawxmit(struct mtr_ctl *ctl, int host, int seq)
+void display_rawxmit(struct mtr_ctl *ctl, int host, int seq)
{
if (ctl->DisplayMode == DisplayRaw)
raw_rawxmit (host, seq);
}
-extern void display_rawping(struct mtr_ctl *ctl, int host, int msec, int seq)
+void display_rawping(struct mtr_ctl *ctl, int host, int msec, int seq)
{
if (ctl->DisplayMode == DisplayRaw)
raw_rawping (ctl, host, msec, seq);
}
-extern void display_rawhost(struct mtr_ctl *ctl, int host, ip_t *ip_addr)
+void display_rawhost(struct mtr_ctl *ctl, int host, ip_t *ip_addr)
{
if (ctl->DisplayMode == DisplayRaw)
raw_rawhost (ctl, host, ip_addr);
}
-extern void display_loop(struct mtr_ctl *ctl)
+void display_loop(struct mtr_ctl *ctl)
{
#ifdef HAVE_GTK
if (ctl->DisplayMode == DisplayGTK)
}
-extern void display_clear(struct mtr_ctl *ctl)
+void display_clear(struct mtr_ctl *ctl)
{
#ifdef HAVE_CURSES
if (ctl->DisplayMode == DisplayCurses)
struct dns_results *next;
};
-struct dns_results *results;
+static struct dns_results *results;
-extern char *strlongip(struct mtr_ctl *ctl, ip_t * ip)
+char *strlongip(struct mtr_ctl *ctl, ip_t * ip)
{
#ifdef ENABLE_IPV6
static char addrstr[INET6_ADDRSTRLEN];
}
-extern struct hostent * dns_forward(const char *name)
+struct hostent * dns_forward(const char *name)
{
struct hostent *host;
}
}
-extern void dns_open(struct mtr_ctl *ctl)
+void dns_open(struct mtr_ctl *ctl)
{
int pid;
}
}
-extern int dns_waitfd (void)
+int dns_waitfd (void)
{
return fromdns[0];
}
-extern void dns_ack(struct mtr_ctl *ctl)
+void dns_ack(struct mtr_ctl *ctl)
{
char buf[2048], host[NI_MAXHOST], name[NI_MAXHOST];
ip_t hostip;
#ifdef ENABLE_IPV6
-extern int dns_waitfd6 (void)
+int dns_waitfd6 (void)
{
return -1;
}
-extern void dns_ack6(void)
+void dns_ack6(void)
{
return;
}
#endif
-extern char *dns_lookup2(struct mtr_ctl *ctl, ip_t * ip)
+char *dns_lookup2(struct mtr_ctl *ctl, ip_t * ip)
{
struct dns_results *r;
char buf[INET6_ADDRSTRLEN + 1];
}
-extern char *dns_lookup(struct mtr_ctl *ctl, ip_t * ip)
+char *dns_lookup(struct mtr_ctl *ctl, ip_t * ip)
{
char *t;
/* XXX check if necessary/exported. */
/* Resolve an IP address to a hostname. */
-extern struct hostent *addr2host( const char *addr, int family ) {
+struct hostent *addr2host( const char *addr, int family ) {
int len = 0;
switch ( family ) {
case AF_INET:
}
-extern int gtk_detect(ATTRIBUTE_UNUSED int *argc, ATTRIBUTE_UNUSED char ***argv)
+int gtk_detect(ATTRIBUTE_UNUSED int *argc, ATTRIBUTE_UNUSED char ***argv)
{
if(getenv("DISPLAY") != NULL) {
/* If we do this here, gtk_init exits on an error. This happens
#endif
}
-extern void gtk_redraw(struct mtr_ctl *ctl)
+void gtk_redraw(struct mtr_ctl *ctl)
{
int max = net_max(ctl);
}
-extern void gtk_open(struct mtr_ctl *ctl)
+void gtk_open(struct mtr_ctl *ctl)
{
GdkPixbuf *icon;
int argc = 1;
}
-extern void gtk_close(void)
+void gtk_close(void)
{
}
-extern int gtk_keyaction(void)
+int gtk_keyaction(void)
{
return 0;
}
#endif
-extern void gtk_loop(struct mtr_ctl *ctl)
+void gtk_loop(struct mtr_ctl *ctl)
{
GIOChannel *net_iochannel, *dns_iochannel;
srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
}
-extern int main(int argc, char **argv)
+int main(int argc, char **argv)
{
struct hostent * host = NULL;
struct addrinfo hints, *res;
/* return the number of microseconds to wait before sending the next
ping */
-extern int calc_deltatime (float waittime)
+int calc_deltatime (float waittime)
{
waittime /= numhosts;
return 1000000 * waittime;
Invoked when the read pipe from the mtr-packet subprocess is readable.
If we have received a complete reply, process it.
*/
-extern void net_process_return(struct mtr_ctl *ctl)
+void net_process_return(struct mtr_ctl *ctl)
{
handle_command_replies(ctl, &packet_command_pipe, net_process_ping);
}
-extern ip_t *net_addr(int at)
+ip_t *net_addr(int at)
{
return (ip_t *)&(host[at].addr);
}
-extern ip_t *net_addrs(int at, int i)
+ip_t *net_addrs(int at, int i)
{
return (ip_t *)&(host[at].addrs[i]);
}
-extern void *net_mpls(int at)
+void *net_mpls(int at)
{
return (struct mplslen *)&(host[at].mplss);
}
-extern void *net_mplss(int at, int i)
+void *net_mplss(int at, int i)
{
return (struct mplslen *)&(host[at].mplss[i]);
}
-extern int net_loss(int at)
+int net_loss(int at)
{
- if ((host[at].xmit - host[at].transit) == 0)
+ if ((host[at].xmit - host[at].transit) == 0)
return 0;
/* times extra 1000 */
return 1000*(100 - (100.0 * host[at].returned / (host[at].xmit - host[at].transit)) );
}
-extern int net_drop(int at)
+int net_drop(int at)
{
return (host[at].xmit - host[at].transit) - host[at].returned;
}
-extern int net_last(int at)
+int net_last(int at)
{
return (host[at].last);
}
-extern int net_best(int at)
+int net_best(int at)
{
return (host[at].best);
}
-extern int net_worst(int at)
+int net_worst(int at)
{
return (host[at].worst);
}
-extern int net_avg(int at)
+int net_avg(int at)
{
return (host[at].avg);
}
-extern int net_gmean(int at)
+int net_gmean(int at)
{
return (host[at].gmean);
}
-extern int net_stdev(int at)
+int net_stdev(int at)
{
if( host[at].returned > 1 ) {
return ( sqrt( host[at].ssd/(host[at].returned -1.0) ) );
}
-extern int net_jitter(int at)
+int net_jitter(int at)
{
return (host[at].jitter);
}
-extern int net_jworst(int at)
+int net_jworst(int at)
{
return (host[at].jworst);
}
-extern int net_javg(int at)
+int net_javg(int at)
{
return (host[at].javg);
}
-extern int net_jinta(int at)
+int net_jinta(int at)
{
return (host[at].jinta);
}
-extern int net_max(struct mtr_ctl *ctl)
+int net_max(struct mtr_ctl *ctl)
{
int at;
int max;
}
-extern int net_min (struct mtr_ctl *ctl)
+int net_min (struct mtr_ctl *ctl)
{
return ( ctl->fstTTL - 1 );
}
-extern int net_returned(int at)
+int net_returned(int at)
{
return host[at].returned;
}
-extern int net_xmit(int at)
+int net_xmit(int at)
{
return host[at].xmit;
}
-extern int net_up(int at)
+int net_up(int at)
{
return host[at].up;
}
-extern char * net_localaddr (void)
+char * net_localaddr (void)
{
return localaddr;
}
-extern void net_end_transit(void)
+void net_end_transit(void)
{
int at;
}
}
-extern int net_send_batch(struct mtr_ctl *ctl)
+int net_send_batch(struct mtr_ctl *ctl)
{
int n_unknown=0, i;
}
-extern int net_open(struct mtr_ctl *ctl, struct hostent * hostent)
+int net_open(struct mtr_ctl *ctl, struct hostent * hostent)
{
int err;
}
-extern void net_reopen(struct mtr_ctl *ctl, struct hostent * addr)
+void net_reopen(struct mtr_ctl *ctl, struct hostent * addr)
{
int at;
}
-extern void net_reset(struct mtr_ctl *ctl)
+void net_reset(struct mtr_ctl *ctl)
{
static struct nethost template = {
.saved_seq_offset = 2 - SAVED_PINGS
/* Close the pipe to the packet generator process, and kill the process */
-extern void net_close(void)
+void net_close(void)
{
close_command_pipe(&packet_command_pipe);
}
-extern int net_waitfd(void)
+int net_waitfd(void)
{
return packet_command_pipe.read_fd;
}
-extern int* net_saved_pings(int at)
+int* net_saved_pings(int at)
{
return host[at].saved;
}
}
-extern void net_save_xmit(int at)
+void net_save_xmit(int at)
{
- if (host[at].saved[SAVED_PINGS-1] != -2)
+ if (host[at].saved[SAVED_PINGS-1] != -2)
net_save_increment();
host[at].saved[SAVED_PINGS-1] = -1;
}
-extern void net_save_return(int at, int seq, int ms)
+void net_save_return(int at, int seq, int ms)
{
int idx;
idx = seq - host[at].saved_seq_offset;
/* Address comparison. */
-extern int addrcmp( char * a, char * b, int family ) {
+int addrcmp( char * a, char * b, int family ) {
int rc = -1;
switch ( family ) {
}
/* Address copy. */
-extern void addrcpy( char * a, char * b, int family ) {
+void addrcpy( char * a, char * b, int family ) {
switch ( family ) {
case AF_INET:
}
/* for GTK frontend */
-extern void net_harvest_fds(struct mtr_ctl *ctl)
+void net_harvest_fds(struct mtr_ctl *ctl)
{
fd_set writefd;
int maxfd = 0;
/* Log an echo request, or a "ping" */
-extern void raw_rawxmit (int host, int seq)
+void raw_rawxmit (int host, int seq)
{
printf ("x %d %d\n", host, seq);
fflush (stdout);
}
/* Log an echo reply, or a "pong" */
-extern void raw_rawping (struct mtr_ctl *ctl, int host, int msec, int seq)
+void raw_rawping (struct mtr_ctl *ctl, int host, int msec, int seq)
{
static int havename[MaxHost];
char *name;
}
-extern void raw_rawhost (struct mtr_ctl *ctl, int host, ip_t * ip_addr)
+void raw_rawhost (struct mtr_ctl *ctl, int host, ip_t * ip_addr)
{
printf ("h %d %s\n", host, strlongip(ctl, ip_addr));
fflush (stdout);
#define MAX_FORMAT_STR 81
-extern void report_open(void)
+void report_open(void)
{
const time_t now = time(NULL);
const char *t = iso_time (&now);
}
#endif
-extern void report_close(struct mtr_ctl *ctl)
+void report_close(struct mtr_ctl *ctl)
{
int i, j, at, max, z, w;
struct mplslen *mpls, *mplss;
}
-extern void txt_open(void)
+void txt_open(void)
{
}
-extern void txt_close(struct mtr_ctl *ctl)
+void txt_close(struct mtr_ctl *ctl)
{
report_close(ctl);
}
-extern void json_open(void)
+void json_open(void)
{
}
-extern void json_close(struct mtr_ctl *ctl)
+void json_close(struct mtr_ctl *ctl)
{
int i, j, at, first, max;
ip_t *addr;
-extern void xml_open(void)
+void xml_open(void)
{
}
-extern void xml_close(struct mtr_ctl *ctl)
+void xml_close(struct mtr_ctl *ctl)
{
int i, j, at, max;
ip_t *addr;
}
-extern void csv_open(void)
+void csv_open(void)
{
}
-extern void csv_close(struct mtr_ctl *ctl, time_t now)
+void csv_close(struct mtr_ctl *ctl, time_t now)
{
int i, j, at, max;
ip_t *addr;
#include "display.h"
#include "select.h"
-extern void select_loop(struct mtr_ctl *ctl){
+void select_loop(struct mtr_ctl *ctl){
fd_set readfd;
fd_set writefd;
int anyset = 0;
#define DEBUG 0
-extern void split_redraw(struct mtr_ctl *ctl)
+void split_redraw(struct mtr_ctl *ctl)
{
int max;
int at;
}
-extern void split_open(void)
+void split_open(void)
{
int i;
#if DEBUG
}
-extern void split_close(void)
+void split_close(void)
{
#if DEBUG
printf("split_close()\n");
}
-extern int split_keyaction(void)
+int split_keyaction(void)
{
#ifdef HAVE_CURSES
unsigned char c = getch();
#include "utils.h"
-extern char *trim(char *str, const char c)
+char *trim(char *str, const char c)
{
char *p = str;
size_t len;
}
/* Parse string, and return positive signed int. */
-extern int strtonum_or_err(const char *str, const char *errmesg, const int type)
+int strtonum_or_err(const char *str, const char *errmesg, const int type)
{
unsigned long int num;
char *end = NULL;
return 0;
}
-extern float strtofloat_or_err(const char *str, const char *errmesg)
+float strtofloat_or_err(const char *str, const char *errmesg)
{
double num;
char *end = NULL;
return 0;
}
-extern void *xmalloc(const size_t size)
+void *xmalloc(const size_t size)
{
void *ret = malloc(size);
return ret;
}
-extern char *xstrdup(const char *str)
+char *xstrdup(const char *str)
{
char *ret;
return 0;
}
/* Meant to be used atexit(close_stdout); */
-extern void close_stdout(void)
+void close_stdout(void)
{
if (close_stream(stdout) != 0 && !(errno == EPIPE)) {
error(0, errno, "write error");
/* ctime() replacement that will reteturn ISO-8601 timestamp string such as:
* 2016-08-29T19:25:02+01:00 */
-extern const char *iso_time(const time_t *t)
+const char *iso_time(const time_t *t)
{
static char s[32];
struct tm *tm;