From 31a4067a68fd28790af3344406d3014a7f10e002 Mon Sep 17 00:00:00 2001 From: jhay Date: Sat, 13 Apr 1996 15:13:30 +0000 Subject: Accept and use the content of packets received that is bigger than the Novell spec, but still only transmit according to the spec. Add a feature to dump the RIP and SAP tables when a SIGINFO signal is received. --- usr.sbin/IPXrouted/IPXrouted.8 | 5 +++++ usr.sbin/IPXrouted/defs.h | 4 ++-- usr.sbin/IPXrouted/main.c | 22 ++++++++++++++++++++-- usr.sbin/IPXrouted/output.c | 5 +++-- usr.sbin/IPXrouted/protocol.h | 5 +++-- usr.sbin/IPXrouted/sap.h | 3 ++- usr.sbin/IPXrouted/sap_output.c | 5 +++-- usr.sbin/IPXrouted/table.h | 6 +++--- usr.sbin/IPXrouted/tables.c | 6 +++++- usr.sbin/IPXrouted/trace.c | 30 +++++++++++++++++++++++++++++- usr.sbin/IPXrouted/trace.h | 3 ++- 11 files changed, 77 insertions(+), 17 deletions(-) (limited to 'usr.sbin/IPXrouted') diff --git a/usr.sbin/IPXrouted/IPXrouted.8 b/usr.sbin/IPXrouted/IPXrouted.8 index 3a1b0cd..79779d5 100644 --- a/usr.sbin/IPXrouted/IPXrouted.8 +++ b/usr.sbin/IPXrouted/IPXrouted.8 @@ -179,6 +179,11 @@ to other routers. Hosts acting as internetwork routers gratuitously supply their routing tables every 30 seconds to all directly connected hosts and networks. +.Pp +If +.Nm IPXrouted +receives a SIGINFO signal the current contents of the RIP and SAP +tables are appended to the file /tmp/ipxrouted.dmp. .Sh SEE ALSO .Xr ipx 3 .Sh HISTORY diff --git a/usr.sbin/IPXrouted/defs.h b/usr.sbin/IPXrouted/defs.h index a5fb1f0..e26dbac 100644 --- a/usr.sbin/IPXrouted/defs.h +++ b/usr.sbin/IPXrouted/defs.h @@ -34,7 +34,7 @@ * * @(#)defs.h 8.1 (Berkeley) 6/5/93 * - * $Id: defs.h,v 1.1 1995/10/26 21:28:14 julian Exp $ + * $Id: defs.h,v 1.2 1995/10/27 10:48:25 julian Exp $ */ #include @@ -87,7 +87,7 @@ extern int r; /* Routing socket to install updates with */ extern int gateway; extern struct sockaddr_ipx ipx_netmask; /* Used in installing routes */ -extern char packet[MAXPACKETSIZE+sizeof(struct ipx)+1]; +extern char packet[MAXRXPACKETSIZE+1]; extern struct rip *msg; extern char **argv0; diff --git a/usr.sbin/IPXrouted/main.c b/usr.sbin/IPXrouted/main.c index 2bac1fe..40e5e7a 100644 --- a/usr.sbin/IPXrouted/main.c +++ b/usr.sbin/IPXrouted/main.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: main.c,v 1.2 1995/10/27 10:48:28 julian Exp $ + * $Id: main.c,v 1.3 1995/12/09 09:42:03 julian Exp $ */ #ifndef lint @@ -79,7 +79,7 @@ int noteremoterequests; /* squawk on requests from non-local nets */ int r; /* Routing socket to install updates with */ struct sockaddr_ipx ipx_netmask; /* Used in installing routes */ -char packet[MAXPACKETSIZE+sizeof(struct ipx)+1]; +char packet[MAXRXPACKETSIZE+1]; char **argv0; @@ -92,6 +92,7 @@ struct sap_packet *sap_msg = void hup(), fkexit(), timer(); void process(int fd, int pkt_type); int getsocket(int type, int proto, struct sockaddr_ipx *sipx); +void getinfo(); int main(argc, argv) @@ -214,6 +215,7 @@ main(argc, argv) signal(SIGHUP, hup); signal(SIGINT, hup); signal(SIGEMT, fkexit); + signal(SIGINFO, getinfo); timer(); nfds = 1 + max(sapsock, ripsock); @@ -343,3 +345,19 @@ fkexit() if (fork() == 0) exit(0); } + +void +getinfo() +{ + FILE *fh; + + fh = fopen("/tmp/ipxrouted.dmp", "a"); + if(fh == NULL) + return; + + dumpriptable(fh); + dumpsaptable(fh, sap_head); + + fclose(fh); +} + diff --git a/usr.sbin/IPXrouted/output.c b/usr.sbin/IPXrouted/output.c index b8975e2..f44d8c8 100644 --- a/usr.sbin/IPXrouted/output.c +++ b/usr.sbin/IPXrouted/output.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: output.c,v 1.1 1995/10/26 21:28:20 julian Exp $ + * $Id: output.c,v 1.2 1995/12/05 04:59:54 julian Exp $ */ #ifndef lint @@ -143,7 +143,8 @@ again: for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++) for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { size = (char *)n - (char *)msg; - if (size > MAXPACKETSIZE - sizeof (struct netinfo)) { + if (size >= ((MAXRIPNETS * sizeof (struct netinfo)) + + sizeof (msg->rip_cmd))) { (*output)(ripsock, flags, dst, size); TRACE_OUTPUT(ifp, dst, size); n = msg->rip_nets; diff --git a/usr.sbin/IPXrouted/protocol.h b/usr.sbin/IPXrouted/protocol.h index e41f5c7..4a7ab85 100644 --- a/usr.sbin/IPXrouted/protocol.h +++ b/usr.sbin/IPXrouted/protocol.h @@ -37,7 +37,7 @@ * * @(#)protocol.h 8.1 (Berkeley) 6/5/93 * - * $Id: protocol.h,v 1.4 1995/10/11 18:57:24 jhay Exp $ + * $Id: protocol.h,v 1.1 1995/10/26 21:28:21 julian Exp $ */ /* @@ -70,7 +70,8 @@ char *ripcmds[RIPCMD_MAX] = #define HOPCNT_INFINITY 16 /* per IPX */ #define DSTNETS_ALL 0xffffffff /* per IPX */ -#define MAXPACKETSIZE 512 /* max broadcast size */ +#define MAXRXPACKETSIZE 1500 /* max rx broadcast size */ +#define MAXRIPNETS 50 /* max nets in tx packet */ extern union ipx_net ipx_anynet; extern union ipx_net ipx_zeronet; diff --git a/usr.sbin/IPXrouted/sap.h b/usr.sbin/IPXrouted/sap.h index 221220f..1c74e3f 100644 --- a/usr.sbin/IPXrouted/sap.h +++ b/usr.sbin/IPXrouted/sap.h @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sap.h,v 1.1 1995/10/26 21:28:22 julian Exp $ + * $Id: sap.h,v 1.2 1995/10/27 10:48:31 julian Exp $ */ #ifndef _SAP_H_ #define _SAP_H_ @@ -46,6 +46,7 @@ char *sapcmds[SAPCMD_MAX] = { "#0", "REQUEST", "RESPONSE", "REQ NEAREST", "RESP NEAREST"}; #endif +#define MAXSAPENTRIES 7 #define SAP_WILDCARD 0xFFFF #define SERVNAMELEN 48 typedef struct sap_info { diff --git a/usr.sbin/IPXrouted/sap_output.c b/usr.sbin/IPXrouted/sap_output.c index 9456d81..a7be79e 100644 --- a/usr.sbin/IPXrouted/sap_output.c +++ b/usr.sbin/IPXrouted/sap_output.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sap_output.c,v 1.2 1995/11/13 21:01:34 julian Exp $ + * $Id: sap_output.c,v 1.3 1995/12/05 04:59:56 julian Exp $ */ /* @@ -126,7 +126,8 @@ sap_supply(dst, flags, ifp, ServType) for (sh = base; sh < &base[SAPHASHSIZ]; sh++) for (sap = sh->forw; sap != (struct sap_entry *)sh; sap = sap->forw) { size = (char *)n - (char *)sap_msg; - if (size > MAXPACKETSIZE - sizeof (struct sap_info)) { + if (size >= ((MAXSAPENTRIES * sizeof (struct sap_info)) + + sizeof (sap_msg->sap_cmd))) { (*output)(sapsock, flags, dst, size); TRACE_SAP_OUTPUT(ifp, dst, size); n = sap_msg->sap; diff --git a/usr.sbin/IPXrouted/table.h b/usr.sbin/IPXrouted/table.h index b029dcc..496e2e4 100644 --- a/usr.sbin/IPXrouted/table.h +++ b/usr.sbin/IPXrouted/table.h @@ -36,7 +36,7 @@ * * @(#)table.h 8.1 (Berkeley) 6/5/93 * - * $Id: table.h,v 1.4 1995/10/11 18:57:30 jhay Exp $ + * $Id: table.h,v 1.1 1995/10/26 21:28:26 julian Exp $ */ /* @@ -102,8 +102,8 @@ struct rt_entry { #define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */ #define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */ -struct rthash nethash[ROUTEHASHSIZ]; -struct rthash hosthash[ROUTEHASHSIZ]; +extern struct rthash nethash[ROUTEHASHSIZ]; +extern struct rthash hosthash[ROUTEHASHSIZ]; struct rt_entry *rtlookup(struct sockaddr *); struct rt_entry *rtfind(struct sockaddr *); void rtadd(struct sockaddr *, struct sockaddr *, short, short, int); diff --git a/usr.sbin/IPXrouted/tables.c b/usr.sbin/IPXrouted/tables.c index 2faf523..15c4398 100644 --- a/usr.sbin/IPXrouted/tables.c +++ b/usr.sbin/IPXrouted/tables.c @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: tables.c,v 1.6 1995/10/11 18:57:31 jhay Exp $ + * $Id: tables.c,v 1.1 1995/10/26 21:28:27 julian Exp $ */ #ifndef lint @@ -58,6 +58,10 @@ static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 6/5/93"; int install = !DEBUG; /* if 1 call kernel */ int delete = 1; + +struct rthash nethash[ROUTEHASHSIZ]; +struct rthash hosthash[ROUTEHASHSIZ]; + /* * Lookup dst in the tables for an exact match. */ diff --git a/usr.sbin/IPXrouted/trace.c b/usr.sbin/IPXrouted/trace.c index bf51116..e703d21 100644 --- a/usr.sbin/IPXrouted/trace.c +++ b/usr.sbin/IPXrouted/trace.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: trace.c,v 1.6 1995/10/11 18:57:33 jhay Exp $ + * $Id: trace.c,v 1.1 1995/10/26 21:28:29 julian Exp $ */ #ifndef lint @@ -381,6 +381,34 @@ dumpsaptable(fd, sh) fprintf(fd, "\n"); } +void +dumpriptable(fd) + FILE *fd; +{ + register 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"); +} + union ipx_net_u net; char * diff --git a/usr.sbin/IPXrouted/trace.h b/usr.sbin/IPXrouted/trace.h index 6a88079..9de7826 100644 --- a/usr.sbin/IPXrouted/trace.h +++ b/usr.sbin/IPXrouted/trace.h @@ -37,7 +37,7 @@ * * @(#)trace.h 8.1 (Berkeley) 6/5/93 * - * $Id: trace.h,v 1.1 1995/10/26 21:28:30 julian Exp $ + * $Id: trace.h,v 1.2 1995/10/27 10:48:31 julian Exp $ */ /* @@ -125,6 +125,7 @@ void trace(struct ifdebug *, struct sockaddr *, char *, int, int); void dumppacket(FILE *, char *, struct sockaddr *, char *, int); void dumpsappacket(FILE *, char *, struct sockaddr *, char *, int); void dumpsaptable(FILE *fd, struct sap_hash *sh); +void dumpriptable(FILE *fd); char *ipxdp_nettoa(union ipx_net); char *ipxdp_ntoa(struct ipx_addr *); -- cgit v1.1