return val;
}
-extern int get_iiwidth (struct mtr_ctl *ctl) {
- return (ctl->ipinfo_no <
- ctl->iiwidth_len) ? iiwidth[ctl->ipinfo_no] :
- iiwidth[ctl->ipinfo_no % ctl->iiwidth_len];
+extern ATTRIBUTE_CONST size_t get_iiwidth_len(void) {
+ return (sizeof(iiwidth) / sizeof((iiwidth)[0]));
+}
+
+extern int get_iiwidth(struct mtr_ctl *ctl) {
+ static const int len = (sizeof(iiwidth) / sizeof((iiwidth)[0]));
+
+ if (ctl->ipinfo_no < len)
+ return iiwidth[ctl->ipinfo_no];
+ return iiwidth[ctl->ipinfo_no % len];
}
extern char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr){
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include "mtr.h"
+
extern void asn_open(struct mtr_ctl *ctl);
extern void asn_close(struct mtr_ctl *ctl);
extern char *fmt_ipinfo(struct mtr_ctl *ctl, ip_t *addr);
+extern ATTRIBUTE_CONST size_t get_iiwidth_len(void);
extern int get_iiwidth(struct mtr_ctl *ctl);
extern int is_printii(struct mtr_ctl *ctl);
#define UNUSED
#endif
+/* The __const__ attribute was added in gcc 2.95. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+# define ATTRIBUTE_CONST __attribute__ ((__const__))
+#else
+# define ATTRIBUTE_CONST /* empty */
+#endif
+
/* stuff used by display such as report, curses... */
#define MAXFLD 20 /* max stats fields to display */
#define FLD_INDEX_SZ 256
char LocalHostname[128];
int ipinfo_no;
int ipinfo_max;
- int iiwidth_len;
int cpacketsize; /* packet size used by ping */
int bitpattern; /* packet bit pattern used by ping */
int tos; /* type of service set in ping packet*/
#ifdef HAVE_IPINFO
int len_tmp = len_hosts;
- if (ctl->ipinfo_no >= 0 && ctl->iiwidth_len) {
- ctl->ipinfo_no %= ctl->iiwidth_len;
+ const size_t iiwidth_len = get_iiwidth_len();
+ if (ctl->ipinfo_no >= 0 && iiwidth_len) {
+ ctl->ipinfo_no %= iiwidth_len;
if (ctl->reportwide) {
len_hosts++; // space
len_tmp += get_iiwidth(ctl);