Beispiel #1
0
void
dumpriptable(FILE *fd)
{
	struct rt_entry *rip;
	struct rthash *hash;
	int x;
	struct rthash *rh = nethash;

	fprintf(fd, "------- RIP table dump. -------\n");
	x = 0;
	fprintf(fd, "Network table.\n");

	for (hash = rh; hash < &rh[ROUTEHASHSIZ]; hash++, x++) {
		fprintf(fd, "HASH %d\n", x);
		rip = hash->rt_forw;
		for (; rip != (struct rt_entry *)hash; rip = rip->rt_forw) {
			fprintf(fd, "  dest %s\t", 
				ipxdp_ntoa(&satoipx_addr(rip->rt_dst)));
			fprintf(fd, "%s metric %d, ticks %d\n",
				ipxdp_ntoa(&satoipx_addr(rip->rt_router)),
				rip->rt_metric,
				rip->rt_ticks);
		}
	}
	fprintf(fd, "\n");
}
Beispiel #2
0
void
traceaction(FILE *fd, char *action, struct rt_entry *rt)
{
	struct sockaddr_ipx *dst, *gate;
	static struct bits {
		int	t_bits;
		char	*t_name;
	} flagbits[] = {
		{ RTF_UP,	"UP" },
		{ RTF_GATEWAY,	"GATEWAY" },
		{ RTF_HOST,	"HOST" },
		{ 0 }
	}, statebits[] = {
		{ RTS_PASSIVE,	"PASSIVE" },
		{ RTS_REMOTE,	"REMOTE" },
		{ RTS_INTERFACE,"INTERFACE" },
		{ RTS_CHANGED,	"CHANGED" },
		{ 0 }
	};
	struct bits *p;
	int first;
	char *cp;

	if (fd == NULL)
		return;
	fprintf(fd, "%s ", action);
	dst = (struct sockaddr_ipx *)&rt->rt_dst;
	gate = (struct sockaddr_ipx *)&rt->rt_router;
	fprintf(fd, "dst %s, ", ipxdp_ntoa(&dst->sipx_addr));
	fprintf(fd, "router %s, metric %d, ticks %d, flags",
	     ipxdp_ntoa(&gate->sipx_addr), rt->rt_metric, rt->rt_ticks);
	cp = " %s";
	for (first = 1, p = flagbits; p->t_bits > 0; p++) {
		if ((rt->rt_flags & p->t_bits) == 0)
			continue;
		fprintf(fd, cp, p->t_name);
		if (first) {
			cp = "|%s";
			first = 0;
		}
	}
	fprintf(fd, " state");
	cp = " %s";
	for (first = 1, p = statebits; p->t_bits > 0; p++) {
		if ((rt->rt_state & p->t_bits) == 0)
			continue;
		fprintf(fd, cp, p->t_name);
		if (first) {
			cp = "|%s";
			first = 0;
		}
	}
	putc('\n', fd);
	if (!tracepackets && (rt->rt_state & RTS_PASSIVE) == 0 && rt->rt_ifp)
		dumpif(fd, rt->rt_ifp);
	fflush(fd);
}
Beispiel #3
0
void
dumpsappacket(FILE *fd, char *dir, struct sockaddr *source, char *cp, int size)
{
	struct sap_packet *msg = (struct sap_packet *)cp;
	struct sap_info *n;
	struct sockaddr_ipx *who = (struct sockaddr_ipx *)source;

	if (msg->sap_cmd && ntohs(msg->sap_cmd) < SAPCMD_MAX)
		fprintf(fd, "%s %s %s#%x", sapcmds[ntohs(msg->sap_cmd)],
		    dir, ipxdp_ntoa(&who->sipx_addr), 
		    ntohs(who->sipx_addr.x_port));
	else {
		fprintf(fd, "Bad cmd 0x%x %s %s#%x\n", ntohs(msg->sap_cmd),
		    dir, ipxdp_ntoa(&who->sipx_addr), 
		    ntohs(who->sipx_addr.x_port));
		fprintf(fd, "size=%d cp=%p packet=%p\n", size, cp, packet);
		return;
	}
	switch (ntohs(msg->sap_cmd)) {

	case SAP_REQ:
	case SAP_RESP:
	case SAP_REQ_NEAR:
	case SAP_RESP_NEAR:
		fprintf(fd, ":\n");
		size -= sizeof (u_short);
		n = msg->sap;
		for (; size > 0; n++, size -= sizeof (struct sap_info)) {
			if (size < sizeof (struct sap_info))
				break;
			fprintf(fd, "  service %04X %-20.20s "
				    "addr %s.%04X metric %d\n",
			     ntohs(n->ServType),
			     n->ServName,
			     ipxdp_ntoa(&n->ipx),
			     ntohs(n->ipx.x_port),
			     ntohs(n->hops));
		}
		break;

	}
}
Beispiel #4
0
void
process(int fd, int pkt_type)
{
	struct sockaddr from;
	int fromlen = sizeof (from), cc, omask;
	struct ipx *ipxdp = (struct ipx *)packet;

	cc = recvfrom(fd, packet, sizeof (packet), 0, &from, &fromlen);
	if (cc <= 0) {
		if (cc < 0 && errno != EINTR)
			syslog(LOG_ERR, "recvfrom: %m");
		return;
	}
	if (tracepackets > 1 && ftrace) {
	    fprintf(ftrace,"rcv %d bytes on %s ", 
		    cc, ipxdp_ntoa(&ipxdp->ipx_dna));
	    fprintf(ftrace," from %s\n", ipxdp_ntoa(&ipxdp->ipx_sna));
	}
	
	if (noteremoterequests && 
	    !ipx_neteqnn(ipxdp->ipx_sna.x_net, ipx_zeronet) &&
	    !ipx_neteq(ipxdp->ipx_sna, ipxdp->ipx_dna))
	{
		syslog(LOG_ERR,
		       "net of interface (%s) != net on ether (%s)!\n",
		       ipxdp_nettoa(ipxdp->ipx_dna.x_net),
		       ipxdp_nettoa(ipxdp->ipx_sna.x_net));
	}
			
	/* We get the IPX header in front of the RIF packet*/
	cc -= sizeof (struct ipx);
#define	mask(s)	(1<<((s)-1))
	omask = sigblock(mask(SIGALRM));
	switch(pkt_type) {
		case SAP_PKT: sap_input(&from, cc);
				break;
		case RIP_PKT: rip_input(&from, cc);
				break;
	}
	sigsetmask(omask);
}
Beispiel #5
0
void
tracesapactionlog(char *action, struct sap_entry *sap)
{
	syslog(LOG_DEBUG, "%-12.12s  service %04X %-20.20s "
		    "addr %s.%04X %c metric %d\n",
		     action,
		     ntohs(sap->sap.ServType),
		     sap->sap.ServName,
		     ipxdp_ntoa(&sap->sap.ipx),
		     ntohs(sap->sap.ipx.x_port),
		     (sap->clone ? 'C' : ' '),
		     ntohs(sap->sap.hops));
}
Beispiel #6
0
void
dumppacket(FILE *fd, char *dir, struct sockaddr *source, char *cp, int size)
{
	struct rip *msg = (struct rip *)cp;
	struct netinfo *n;
	struct sockaddr_ipx *who = (struct sockaddr_ipx *)source;

	if (msg->rip_cmd && ntohs(msg->rip_cmd) < RIPCMD_MAX)
		fprintf(fd, "%s %s %s#%x", ripcmds[ntohs(msg->rip_cmd)],
		    dir, ipxdp_ntoa(&who->sipx_addr), 
		    ntohs(who->sipx_addr.x_port));
	else {
		fprintf(fd, "Bad cmd 0x%x %s %s#%x\n", ntohs(msg->rip_cmd),
		    dir, ipxdp_ntoa(&who->sipx_addr), 
		    ntohs(who->sipx_addr.x_port));
		fprintf(fd, "size=%d cp=%p packet=%p\n", size, cp, packet);
		return;
	}
	switch (ntohs(msg->rip_cmd)) {

	case RIPCMD_REQUEST:
	case RIPCMD_RESPONSE:
		fprintf(fd, ":\n");
		size -= sizeof (u_short);
		n = msg->rip_nets;
		for (; size > 0; n++, size -= sizeof (struct netinfo)) {
			if (size < sizeof (struct netinfo))
				break;
			fprintf(fd, "\tnet %s metric %d ticks %d\n",
			     ipxdp_nettoa(n->rip_dst),
			     ntohs(n->rip_metric),
			     ntohs(n->rip_ticks));
		}
		break;

	}
}
Beispiel #7
0
void
dumpsaptable(FILE *fd, struct sap_hash *sh)
{
	struct sap_entry *sap;
	struct sap_hash *hash;
	int x = 0;

	fprintf(fd, "------- SAP table dump. -------\n");
	for (hash = sh; hash < &sh[SAPHASHSIZ]; hash++, x++) {
		fprintf(fd, "HASH %d\n", x);
		sap = hash->forw;
		for (; sap != (struct sap_entry *)hash; sap = sap->forw) {
			fprintf(fd, "  service %04X %-20.20s "
				    "addr %s.%04X %c metric %d\n",
				     ntohs(sap->sap.ServType),
				     sap->sap.ServName,
				     ipxdp_ntoa(&sap->sap.ipx),
				     ntohs(sap->sap.ipx.x_port),
				     (sap->clone ? 'C' : ' '),
				     ntohs(sap->sap.hops));
		}
	}
	fprintf(fd, "\n");
}
Beispiel #8
0
void
traceactionlog(char *action, struct rt_entry *rt)
{
	struct sockaddr_ipx *dst, *gate;
	static struct bits {
		int	t_bits;
		char	*t_name;
	} flagbits[] = {
		{ RTF_UP,	"UP" },
		{ RTF_GATEWAY,	"GATEWAY" },
		{ RTF_HOST,	"HOST" },
		{ 0 }
	}, statebits[] = {
		{ RTS_PASSIVE,	"PASSIVE" },
		{ RTS_REMOTE,	"REMOTE" },
		{ RTS_INTERFACE,"INTERFACE" },
		{ RTS_CHANGED,	"CHANGED" },
		{ 0 }
	};
	struct bits *p;
	int first;
	char *cp;
	char *lstr, *olstr;

	dst = (struct sockaddr_ipx *)&rt->rt_dst;
	gate = (struct sockaddr_ipx *)&rt->rt_router;
	asprintf(&lstr, "%s dst %s,", action, ipxdp_ntoa(&dst->sipx_addr));
	olstr = lstr;
	asprintf(&lstr, "%s router %s, metric %d, ticks %d, flags",
	     olstr, ipxdp_ntoa(&gate->sipx_addr), rt->rt_metric, rt->rt_ticks);
	free(olstr);
	olstr = lstr;
	cp = "%s %s";
	for (first = 1, p = flagbits; p->t_bits > 0; p++) {
		if ((rt->rt_flags & p->t_bits) == 0)
			continue;
		asprintf(&lstr, cp, olstr, p->t_name);
		free(olstr);
		olstr = lstr;
		if (first) {
			cp = "%s|%s";
			first = 0;
		}
	}
	asprintf(&lstr, "%s state", olstr);
	free(olstr);
	olstr = lstr;
	cp = "%s %s";
	for (first = 1, p = statebits; p->t_bits > 0; p++) {
		if ((rt->rt_state & p->t_bits) == 0)
			continue;
		asprintf(&lstr, cp, olstr, p->t_name);
		free(olstr);
		olstr = lstr;
		if (first) {
			cp = "%s|%s";
			first = 0;
		}
	}
	syslog(LOG_DEBUG, "%s", lstr);
	free(lstr);
}