X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=interface.c;h=0b0d5791e6102d66fd89298b0322f1f1275c2f2a;hb=29fc7923e84b46f29a113b54921d2bf2efacd265;hp=d4688094fef369ec0f2d0b1f26b03b1eb1419d17;hpb=4680b0f8c728a69a24e7089b777f03899bab6c9f;p=~andy%2Ffetchmail diff --git a/interface.c b/interface.c index d4688094..0b0d5791 100644 --- a/interface.c +++ b/interface.c @@ -63,8 +63,6 @@ struct interface_pair_s { struct in_addr interface_mask; } *interface_pair; -static char *netdevfmt; - /* * Count of packets to see on an interface before monitor considers it up. * Needed because when pppd shuts down the link, the packet counts go up @@ -74,6 +72,9 @@ static char *netdevfmt; #define MONITOR_SLOP 5 #ifdef linux +#define have_interface_init + +static char *netdevfmt; void interface_init(void) /* figure out which /proc/net/dev format to use */ @@ -173,7 +174,7 @@ static int get_ifinfo(const char *ifname, ifinfo_t *ifinfo) else { char *sp = strchr(ifname, '/'); - + /* hide slash and trailing info from ifname */ if (sp) *sp = '\0'; result = _get_ifinfoGT_(socket_fd, stats_file, ifname, ifinfo); @@ -270,7 +271,7 @@ get_ifinfo(const char *ifname, ifinfo_t *ifinfo) { kvm_read(kvmfd, ifnet_addr, &ifnet, sizeof(ifnet)); kvm_read(kvmfd, (unsigned long) ifnet.if_name, tname, sizeof tname); - snprintf(tname, sizeof tname, "%s%d", tname, ifnet.if_unit); + snprintf(tname + strlen(tname), sizeof(tname) - strlen(tname), "%d", ifnet.if_unit); if (!strcmp(tname, iname)) { @@ -417,7 +418,7 @@ get_ifinfo(const char *ifname, ifinfo_t *ifinfo) GT_("get_ifinfo: sysctl (iflist estimate) failed")); exit(1); } - if ((buf = malloc(needed)) == NULL) + if ((buf = (char *)malloc(needed)) == NULL) { report(stderr, GT_("get_ifinfo: malloc failed")); @@ -544,13 +545,8 @@ get_ifinfo_end: #endif /* __FREEBSD_USE_SYSCTL_GET_IFFINFO */ -#else - -void interface_init(void) {}; - #endif - #ifndef HAVE_INET_ATON /* * Note: This is not a true replacement for inet_aton(), as it won't @@ -738,3 +734,7 @@ int interface_approve(struct hostdata *hp, flag domonitor) return(TRUE); } #endif /* CAN_MONITOR */ + +#ifndef have_interface_init +void interface_init(void) {} +#endif