]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
cleanup: move definitions and struct declarations to mtr.h
authorSami Kerola <kerolasa@iki.fi>
Sun, 9 Oct 2016 20:03:29 +0000 (21:03 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 18:29:20 +0000 (19:29 +0100)
It is best to keep all of these in one location.

mtr.h
net.c
net.h

diff --git a/mtr.h b/mtr.h
index f1a73c110fcdbbf60e2174b0170a7eb31c06ed27..524bba855186c3617b273df6a1538f2fc1a94395 100644 (file)
--- 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 a2afb158f47f15cf27ef8b1fdd714aeca08bc1ab..0bb8b8400fa530112c84a95d9b0a8a52aa1c3575 100644 (file)
--- 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 587bd680fbda73db8c9a0d187a926eae8c8647c1..0de6d669c1ea0fb3e592580b32f17033d8d4f7b4 100644 (file)
--- 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
-
-