From: Sami Kerola Date: Sun, 9 Oct 2016 20:03:29 +0000 (+0100) Subject: cleanup: move definitions and struct declarations to mtr.h X-Git-Tag: v0.88~21^2^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b43ded53bfdd8c7bf1d1b8f5926fa89ae7c0b6c4;p=thirdparty%2Fmtr.git cleanup: move definitions and struct declarations to mtr.h It is best to keep all of these in one location. --- diff --git a/mtr.h b/mtr.h index f1a73c1..524bba8 100644 --- a/mtr.h +++ b/mtr.h @@ -53,6 +53,21 @@ typedef struct in_addr ip_t; #define MAXFLD 20 /* max stats fields to display */ #define FLD_INDEX_SZ 256 +/* net related definitions */ +#define SAVED_PINGS 200 +#define MAXPATH 8 +#define MaxHost 256 +#define MinPort 1024 +#define MaxPort 65535 +#define MAXPACKET 4470 /* largest test packet size */ +#define MINPACKET 28 /* 20 bytes IP header and 8 bytes ICMP or UDP */ +#define MAXLABELS 8 /* http://kb.juniper.net/KB2190 (+ 3 just in case) */ + +/* Stream Control Transmission Protocol is defined in netinet/in.h */ +#ifdef IPPROTO_SCTP +# define HAS_SCTP 1 +#endif + #ifndef HAVE_SOCKLEN_T typedef int socklen_t; #endif @@ -98,4 +113,25 @@ struct mtr_ctl { DisplayMode:5; }; +/* dynamic field drawing */ +struct fields { + const unsigned char key; + const char *descr; + const char *title; + const char *format; + const int length; + int (*net_xxx)(int); +}; +/* defined in mtr.c */ +extern const struct fields data_fields[MAXFLD]; + +/* MPLS label object */ +struct mplslen { + unsigned long label[MAXLABELS]; /* label value */ + uint8_t exp[MAXLABELS]; /* experimental bits */ + uint8_t ttl[MAXLABELS]; /* MPLS TTL */ + char s[MAXLABELS]; /* bottom of stack */ + char labels; /* how many labels did we get? */ +}; + #endif /* MTR_MTR_H */ diff --git a/net.c b/net.c index a2afb15..0bb8b84 100644 --- a/net.c +++ b/net.c @@ -54,6 +54,9 @@ #include "dns.h" #include "utils.h" +#define MinSequence 33000 +#define MaxSequence 65536 + static int packetsize; /* packet size used by ping */ static int spacketsize; /* packet size used by sendto */ diff --git a/net.h b/net.h index 587bd68..0de6d66 100644 --- a/net.h +++ b/net.h @@ -71,7 +71,6 @@ extern int net_xmit(int at); extern int net_up(int at); -#define SAVED_PINGS 200 extern int* net_saved_pings(int at); extern void net_save_xmit(int at); extern void net_save_return(int at, int seq, int ms); @@ -81,51 +80,3 @@ extern void addrcpy( char * a, char * b, int af ); extern void net_add_fds(fd_set *writefd, int *maxfd); extern void net_process_fds(struct mtr_ctl *ctl, fd_set *writefd); - -#define MAXPATH 8 -#define MaxHost 256 -#define MinSequence 33000 -#define MaxSequence 65536 -#define MinPort 1024 -#define MaxPort 65535 - -#define MAXPACKET 4470 /* largest test packet size */ -#define MINPACKET 28 /* 20 bytes IP header and 8 bytes ICMP or UDP */ -#define MAXLABELS 8 /* http://kb.juniper.net/KB2190 (+ 3 just in case) */ - -#if defined (__STDC__) && __STDC__ -#define CONST const -#else -#define CONST /* */ -#endif - - -/* XXX This doesn't really belong in this header file, but as the - right c-files include it, it will have to do for now. */ - -/* dynamic field drawing */ -struct fields { - CONST unsigned char key; - CONST char *descr; - CONST char *title; - CONST char *format; - int length; - int (*net_xxx)(int); -}; - -extern const struct fields data_fields[MAXFLD]; - -/* MPLS label object */ -struct mplslen { - unsigned long label[MAXLABELS]; /* label value */ - uint8_t exp[MAXLABELS]; /* experimental bits */ - uint8_t ttl[MAXLABELS]; /* MPLS TTL */ - char s[MAXLABELS]; /* bottom of stack */ - char labels; /* how many labels did we get? */ -}; - -#ifdef IPPROTO_SCTP - #define HAS_SCTP -#endif - -