Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:sjcundy:AccessGrid
mtrace
mtrace-5.2-fix.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File mtrace-5.2-fix.patch of Package mtrace
--- mtrace-5.2/Makefile.fix 1998-12-04 14:48:14.000000000 +1000 +++ mtrace-5.2/Makefile 2004-09-26 17:07:26.000000000 +1000 @@ -8,9 +8,9 @@ # #MCAST_INCLUDE= -I/sys # -CFLAGS= -O ${MCAST_INCLUDE} ## SunOS, OSF1, FreeBSD, IRIX +#CFLAGS= -O ${MCAST_INCLUDE} ## SunOS, OSF1, FreeBSD, IRIX #CFLAGS= -O ${MCAST_INCLUDE} -DRAW_OUTPUT_IS_RAW ## OpenBSD -#CFLAGS= -O ${MCAST_INCLUDE} -D__BSD_SOURCE -DRAW_OUTPUT_IS_RAW -DRAW_INPUT_IS_RAW ## Linux +CFLAGS= -O ${MCAST_INCLUDE} -D__BSD_SOURCE -DRAW_OUTPUT_IS_RAW -DRAW_INPUT_IS_RAW ## Linux #CFLAGS= -O ${MCAST_INCLUDE} -DSYSV -DSUNOS5 ## Solaris 2.x #LIBS=-lsocket -lnsl ## Solaris 2.x MTRACE_SRCS= mtrace.c --- mtrace-5.2/mtrace.c.fix 1998-12-04 14:48:19.000000000 +1000 +++ mtrace-5.2/mtrace.c 2004-09-26 17:44:55.000000000 +1000 @@ -124,6 +124,7 @@ #include <ctype.h> #include <errno.h> #include <syslog.h> +#include <time.h> #include <netdb.h> #include <sys/param.h> #include <sys/types.h> @@ -279,13 +280,14 @@ #if !(defined(BSD) && (BSD >= 199103)) extern int errno; extern int sys_nerr; -extern char * sys_errlist[]; +/*extern char * sys_errlist[];*/ #endif #define RECV_BUF_SIZE 8192 char *send_buf, *recv_buf; int igmp_socket; -u_int32 allrtrs_group; +u_int32 allhosts_group; /* All hosts addr in net order */ +u_int32 allrtrs_group; /* All-Routers " in net order */ char router_alert[4]; /* Router Alert IP Option */ #ifndef IPOPT_RA #define IPOPT_RA 148 @@ -368,7 +370,7 @@ void check_vif_state __P((void)); int main __P((int argc, char *argv[])); -void log __P((int, int, char *, ...)); +void error_log __P((int, int, char *, ...)); /* @@ -382,13 +384,13 @@ recv_buf = (char *)malloc(RECV_BUF_SIZE); if (recv_buf == 0) - log(LOG_ERR, 0, "Out of memory allocating recv_buf!"); + error_log(LOG_ERR, 0, "Out of memory allocating recv_buf!"); send_buf = (char *)malloc(RECV_BUF_SIZE); if (send_buf == 0) - log(LOG_ERR, 0, "Out of memory allocating send_buf!"); + error_log(LOG_ERR, 0, "Out of memory allocating send_buf!"); if ((igmp_socket = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP)) < 0) - log(LOG_ERR, errno, "IGMP socket"); + error_log(LOG_ERR, errno, "IGMP socket"); k_hdr_include(TRUE); /* include IP header when sending */ k_set_rcvbuf(48*1024); /* lots of input buffering */ @@ -406,6 +408,7 @@ #ifndef INADDR_ALLRTRS_GROUP #define INADDR_ALLRTRS_GROUP 0xe0000002 /* 224.0.0.2 */ #endif + allhosts_group = htonl(INADDR_ALLHOSTS_GROUP); allrtrs_group = htonl(INADDR_ALLRTRS_GROUP); router_alert[0] = IPOPT_RA; /* Router Alert */ @@ -471,7 +474,7 @@ else if (ip->ip_len == IGMP_MINLEN + 8) ip_addlen = 0; else - log(LOG_ERR, 0, "while checking for Solaris bug: Sent %d bytes and got back %d!", IGMP_MINLEN + 8, ip->ip_len); + error_log(LOG_ERR, 0, "while checking for Solaris bug: Sent %d bytes and got back %d!", IGMP_MINLEN + 8, ip->ip_len); break; } @@ -481,35 +484,26 @@ /* * Construct an IGMP message in the output packet buffer. The caller may - * have already placed data in that buffer, of length 'datalen'. Then send - * the message from the interface with IP address 'src' to destination 'dst'. + * have already placed data in that buffer, of length 'datalen'. */ void -send_igmp(src, dst, type, code, group, datalen) +build_igmp(src, dst, type, code, group, datalen) u_int32 src, dst; int type, code; u_int32 group; int datalen; { - struct sockaddr_in sdst; struct ip *ip; struct igmp *igmp; - int setloop = 0; - static int raset = 0; - int sendra = 0; - int sendlen; ip = (struct ip *)send_buf; ip->ip_src.s_addr = src; ip->ip_dst.s_addr = dst; ip->ip_len = MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen; - sendlen = ip->ip_len; -#ifdef SUNOS5 - ip->ip_len += ip_addlen; -#endif #ifdef RAW_OUTPUT_IS_RAW - ip->ip_len = htons(ip->ip_len); + ip->ip_len = htons(ip->ip_len); #endif + ip->ip_ttl = MAXTTL; igmp = (struct igmp *)(send_buf + MIN_IP_HEADER_LEN); igmp->igmp_type = type; @@ -517,54 +511,58 @@ igmp->igmp_group.s_addr = group; igmp->igmp_cksum = 0; igmp->igmp_cksum = inet_cksum((u_short *)igmp, - IGMP_MINLEN + datalen); + IGMP_MINLEN + datalen); +} - if (IN_MULTICAST(ntohl(dst))) { - k_set_if(src); - setloop = 1; - k_set_loop(TRUE); - if (dst != allrtrs_group) - sendra = 1; - } +/* + * Call build_igmp() to build an IGMP message in the output packet buffer. + * Then send the message from the interface with IP address 'src' to + * destination 'dst'. + */ +void +send_igmp(src, dst, type, code, group, datalen) + u_int32 src, dst; + int type, code; + u_int32 group; + int datalen; +{ + struct sockaddr_in sdst; + int setloop = 0; - if (sendopts && sendra && !raset) { - setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS, - router_alert, sizeof(router_alert)); - raset = 1; - } else if (!sendra && raset) { -#ifdef SUNOS5 - /* - * SunOS5 < 5.6 cannot properly reset the IP_OPTIONS "socket" - * option. Instead, set up a string of 4 EOL's. - */ - setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS, - eol, sizeof(eol)); -#else - setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS, - NULL, 0); -#endif - raset = 0; + build_igmp(src, dst, type, code, group, datalen); + + if (IN_MULTICAST(ntohl(dst))) { + k_set_if(src); + if (type != IGMP_DVMRP || dst == allhosts_group) { + setloop = 1; + k_set_loop(TRUE); + } } bzero(&sdst, sizeof(sdst)); sdst.sin_family = AF_INET; -#if (defined(BSD) && (BSD >= 199103)) +#ifdef HAVE_SA_LEN sdst.sin_len = sizeof(sdst); #endif sdst.sin_addr.s_addr = dst; - if (sendto(igmp_socket, send_buf, sendlen, 0, - (struct sockaddr *)&sdst, sizeof(sdst)) < 0) { - log(LOG_WARNING, errno, "sendto to %s on %s", - inet_fmt(dst, s1), inet_fmt(src, s2)); + if (sendto(igmp_socket, send_buf, + MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen, 0, + (struct sockaddr *)&sdst, sizeof(sdst)) < 0) { + if (errno == ENETDOWN) + check_vif_state(); + else + error_log(LOG_WARNING, errno, "sendto to %s on %s", + inet_fmt(dst, s1), inet_fmt(src, s2)); } if (setloop) - k_set_loop(FALSE); + k_set_loop(FALSE); + + error_log(LOG_DEBUG, 0, "SENT %s from %-15s to %s", + type == IGMP_MTRACE ? "mtrace request" : "ask_neighbors", + src == INADDR_ANY ? "INADDR_ANY" : inet_fmt(src, s1), + inet_fmt(dst, s2)); - log(LOG_DEBUG, 0, "SENT %s from %-15s to %s", - type == IGMP_MTRACE ? "mtrace request" : "ask_neighbors", - src == INADDR_ANY ? "INADDR_ANY" : inet_fmt(src, s1), - inet_fmt(dst, s2)); } /* @@ -627,7 +625,7 @@ { if (setsockopt(igmp_socket, SOL_SOCKET, SO_RCVBUF, (char *)&bufsize, sizeof(bufsize)) < 0) - log(LOG_ERR, errno, "setsockopt SO_RCVBUF %u", bufsize); + error_log(LOG_ERR, errno, "setsockopt SO_RCVBUF %u", bufsize); } @@ -638,7 +636,7 @@ #ifdef IP_HDRINCL if (setsockopt(igmp_socket, IPPROTO_IP, IP_HDRINCL, (char *)&bool, sizeof(bool)) < 0) - log(LOG_ERR, errno, "setsockopt IP_HDRINCL %u", bool); + error_log(LOG_ERR, errno, "setsockopt IP_HDRINCL %u", bool); #endif } @@ -651,7 +649,7 @@ ttl = t; if (setsockopt(igmp_socket, IPPROTO_IP, IP_MULTICAST_TTL, (char *)&ttl, sizeof(ttl)) < 0) - log(LOG_ERR, errno, "setsockopt IP_MULTICAST_TTL %u", ttl); + error_log(LOG_ERR, errno, "setsockopt IP_MULTICAST_TTL %u", ttl); } @@ -664,7 +662,7 @@ loop = l; if (setsockopt(igmp_socket, IPPROTO_IP, IP_MULTICAST_LOOP, (char *)&loop, sizeof(loop)) < 0) - log(LOG_ERR, errno, "setsockopt IP_MULTICAST_LOOP %u", loop); + error_log(LOG_ERR, errno, "setsockopt IP_MULTICAST_LOOP %u", loop); } void @@ -676,7 +674,7 @@ adr.s_addr = ifa; if (setsockopt(igmp_socket, IPPROTO_IP, IP_MULTICAST_IF, (char *)&adr, sizeof(adr)) < 0) - log(LOG_ERR, errno, "setsockopt IP_MULTICAST_IF %s", + error_log(LOG_ERR, errno, "setsockopt IP_MULTICAST_IF %s", inet_fmt(ifa, s1)); } @@ -692,7 +690,7 @@ if (setsockopt(igmp_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq)) < 0) - log(LOG_WARNING, errno, "can't join group %s on interface %s", + error_log(LOG_WARNING, errno, "can't join group %s on interface %s", inet_fmt(grp, s1), inet_fmt(ifa, s2)); } @@ -709,7 +707,7 @@ if (setsockopt(igmp_socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, (char *)&mreq, sizeof(mreq)) < 0) - log(LOG_WARNING, errno, "can't leave group %s on interface %s", + error_log(LOG_WARNING, errno, "can't leave group %s on interface %s", inet_fmt(grp, s1), inet_fmt(ifa, s2)); } @@ -1323,6 +1321,7 @@ iphdrlen = ip->ip_hl << 2; #ifdef RAW_INPUT_IS_RAW ipdatalen = ntohs(ip->ip_len); + ipdatalen -= iphdrlen; #else ipdatalen = ip->ip_len; #endif @@ -1972,11 +1971,12 @@ break; case NEITHER: - if (ghave != NEITHER) + if (ghave != NEITHER) { if (tunstats) printf(" "); else printf(" "); + } break; } @@ -2027,17 +2027,17 @@ if (debug > 2) { - printf("\t\t\t\tv_in: %ld ", ntohl(s->tr_vifin)); - printf("v_out: %ld ", ntohl(s->tr_vifout)); - printf("pkts: %ld\n", ntohl(s->tr_pktcnt)); - printf("\t\t\t\tv_in: %ld ", ntohl(r->tr_vifin)); - printf("v_out: %ld ", ntohl(r->tr_vifout)); - printf("pkts: %ld\n", ntohl(r->tr_pktcnt)); - printf("\t\t\t\tv_in: %ld ",ntohl(s->tr_vifin)-ntohl(r->tr_vifin)); - printf("v_out: %ld ", ntohl(s->tr_vifout) - ntohl(r->tr_vifout)); - printf("pkts: %ld ", ntohl(s->tr_pktcnt) - ntohl(r->tr_pktcnt)); + printf("\t\t\t\tv_in: %u ", ntohl(s->tr_vifin)); + printf("v_out: %u ", ntohl(s->tr_vifout)); + printf("pkts: %u\n", ntohl(s->tr_pktcnt)); + printf("\t\t\t\tv_in: %u ", ntohl(r->tr_vifin)); + printf("v_out: %u ", ntohl(r->tr_vifout)); + printf("pkts: %u\n", ntohl(r->tr_pktcnt)); + printf("\t\t\t\tv_in: %u ",ntohl(s->tr_vifin)-ntohl(r->tr_vifin)); + printf("v_out: %u ", ntohl(s->tr_vifout) - ntohl(r->tr_vifout)); + printf("pkts: %u ", ntohl(s->tr_pktcnt) - ntohl(r->tr_pktcnt)); printf("time: %d\n", timediff); - printf("\t\t\t\treset: %x hoptime: %lx\n", *rst, ntohl(s->tr_qarr)); + printf("\t\t\t\treset: %x hoptime: %x\n", *rst, ntohl(s->tr_qarr)); } } @@ -2148,7 +2148,7 @@ if (debug > 2) { printf("\t\tip=%s, r=%d, res=%d\n", inet_fmt(b->tr_inaddr, s1), *r, res); if (res) - printf("\t\tbase=%ld, prev=%ld, new=%ld\n", ntohl(b->tr_pktcnt), + printf("\t\tbase=%u, prev=%u, new=%u\n", ntohl(b->tr_pktcnt), ntohl(p->tr_pktcnt), ntohl(n->tr_pktcnt)); } if (*r & BUG_RESET) { @@ -2286,16 +2286,16 @@ printf(" v ^\n"); } if (debug > 2) { - printf("\t\t\t\tv_in: %ld ", ntohl(n->tr_vifin)); - printf("v_out: %ld ", ntohl(n->tr_vifout)); - printf("pkts: %ld\n", ntohl(n->tr_pktcnt)); - printf("\t\t\t\tv_in: %ld ", ntohl(b->tr_vifin)); - printf("v_out: %ld ", ntohl(b->tr_vifout)); - printf("pkts: %ld\n", ntohl(b->tr_pktcnt)); - printf("\t\t\t\tv_in: %ld ", ntohl(n->tr_vifin) - ntohl(b->tr_vifin)); - printf("v_out: %ld ", ntohl(n->tr_vifout) - ntohl(b->tr_vifout)); - printf("pkts: %ld\n", ntohl(n->tr_pktcnt) - ntohl(b->tr_pktcnt)); - printf("\t\t\t\treset: %x hoptime: %lx\n", *r, ntohl(n->tr_qarr)); + printf("\t\t\t\tv_in: %u ", ntohl(n->tr_vifin)); + printf("v_out: %u ", ntohl(n->tr_vifout)); + printf("pkts: %u\n", ntohl(n->tr_pktcnt)); + printf("\t\t\t\tv_in: %u ", ntohl(b->tr_vifin)); + printf("v_out: %u ", ntohl(b->tr_vifout)); + printf("pkts: %u\n", ntohl(b->tr_pktcnt)); + printf("\t\t\t\tv_in: %u ", ntohl(n->tr_vifin) - ntohl(b->tr_vifin)); + printf("v_out: %u ", ntohl(n->tr_vifout) - ntohl(b->tr_vifout)); + printf("pkts: %u\n", ntohl(n->tr_pktcnt) - ntohl(b->tr_pktcnt)); + printf("\t\t\t\treset: %x hoptime: %x\n", *r, ntohl(n->tr_qarr)); } while (TRUE) { @@ -2957,7 +2957,7 @@ if (base.rtime == 0) { printf("Timed out receiving responses\n"); - if (IN_MULTICAST(ntohl(tdst))) + if (IN_MULTICAST(ntohl(tdst))) { if (tdst == query_cast) printf("Perhaps no local router has a route for source %s\n", inet_fmt(qsrc, s1)); @@ -2967,6 +2967,7 @@ or multicast at ttl %d doesn't reach its last-hop router for that source\n", inet_fmt(qdst, s2), inet_fmt(qgrp, s3), inet_fmt(qsrc, s1), qttl ? qttl : MULTICAST_TTL1); + } exit(1); } @@ -3088,7 +3089,7 @@ void check_vif_state() { - log(LOG_WARNING, errno, "sendto"); + error_log(LOG_WARNING, errno, "sendto"); } /* @@ -3098,7 +3099,7 @@ */ #ifdef __STDC__ void -log(int severity, int syserr, char *format, ...) +error_log(int severity, int syserr, char *format, ...) { va_list ap; char fmt[100]; @@ -3107,7 +3108,7 @@ #else /*VARARGS3*/ void -log(severity, syserr, format, va_alist) +error_log(severity, syserr, format, va_alist) int severity, syserr; char *format; va_dcl @@ -3129,10 +3130,8 @@ vfprintf(stderr, fmt, ap); if (syserr == 0) fprintf(stderr, "\n"); - else if (syserr < sys_nerr) - fprintf(stderr, ": %s\n", sys_errlist[syserr]); else - fprintf(stderr, ": errno %d\n", syserr); + fprintf(stderr, ": %s\n", strerror(syserr)); } if (severity <= LOG_ERR) exit(-1); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor