From: "Grigory Batalov" Subject: checking IPX route Date: Wed, 7 Aug 2002 16:43:26 +0400 Sender: linux-msdos-owner@vger.kernel.org Message-ID: <20020807164326.782b1332.grisxa@mail.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart_Wed__7_Aug_2002_16:43:26_+0400_081d5c38" Return-path: List-Id: To: linux-msdos@vger.kernel.org This is a multi-part message in MIME format. --Multipart_Wed__7_Aug_2002_16:43:26_+0400_081d5c38 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit As Stas Sergeev said, we need to check presence of IPX route before trying to add it. Here is my version of such checking. Patch applies after Stas' last ipx_root.diff . -- Grigory Batalov. --Multipart_Wed__7_Aug_2002_16:43:26_+0400_081d5c38 Content-Type: text/plain; name="dosemu-1.1.3-ipx_route.patch" Content-Disposition: attachment; filename="dosemu-1.1.3-ipx_route.patch" Content-Transfer-Encoding: 7bit diff -ruN dosemu-1.1.3.orig/src/base/misc/utilities.c dosemu-1.1.3/src/base/misc/utilities.c --- dosemu-1.1.3.orig/src/base/misc/utilities.c Wed Aug 7 15:50:56 2002 +++ dosemu-1.1.3/src/base/misc/utilities.c Wed Aug 7 15:52:35 2002 @@ -22,6 +22,7 @@ #include "Linux/vt.h" #include #include +#include #include "emu.h" #include "machcompat.h" @@ -354,6 +355,34 @@ { procbufptr = procbuf; proclastpos = 0; } + +int check_proc_ipx_route(unsigned long targetNet, unsigned long network, unsigned char node[]) +{ char buf[13]; + + snprintf(buf,9,"%08lX",(unsigned long)htonl(targetNet)); + buf[8]='\0'; + + while (strncmp(procbufptr,buf,8) != 0) + { while (*procbufptr != '\n' && *procbufptr != 0) + procbufptr++; + if (*procbufptr == 0) + return 0; + procbufptr++; + } + + snprintf(buf,9,"%08lX",(unsigned long)htonl(network)); + buf[8]='\0'; + if (strncmp(procbufptr+11,buf,8) != 0) + return 0; + + snprintf(buf,13,"%02X%02X%02X%02X%02X%02X",node[0],node[1], + node[2],node[3],node[4],node[5]); + buf[12]='\0'; + if (strncmp(procbufptr+24,buf,12) != 0) + return 0; + + return 1; + } char *get_proc_string_by_key(char *key) { diff -ruN dosemu-1.1.3.orig/src/dosext/net/net/ipxglt.c dosemu-1.1.3/src/dosext/net/net/ipxglt.c --- dosemu-1.1.3.orig/src/dosext/net/net/ipxglt.c Wed Aug 7 15:51:54 2002 +++ dosemu-1.1.3/src/dosext/net/net/ipxglt.c Wed Aug 7 15:52:35 2002 @@ -34,6 +34,8 @@ #include "emu.h" #include "dosemu_select.h" +#include "utilities.h" + #define FALSE 0 #define TRUE 1 #define TIMEOUT 250000 @@ -220,20 +222,32 @@ *hops = htons(RipResponse.Hops); *ticks = htons(RipResponse.Ticks); - retCode = AddRoute( network, ipxs.sipx_network, - ipxs.sipx_node ); - if( retCode < 0 ) { - n_printf("IPX: Failure %d adding route <%08lx through %08lx:%02x%02x%02x%02x%02x%02x>\n", + + open_proc_scan("/proc/net/ipx_route"); + if (check_proc_ipx_route(network,ipxs.sipx_network,ipxs.sipx_node)) + { n_printf("IPX: Route <%08lx through %08lx:%02x%02x%02x%02x%02x%02x> exists\n", + (unsigned long int)htonl(network), (unsigned long int)htonl(ipxs.sipx_network), + ipxs.sipx_node[0],ipxs.sipx_node[1],ipxs.sipx_node[2], + ipxs.sipx_node[3],ipxs.sipx_node[4],ipxs.sipx_node[5] ); + } + else + { retCode = AddRoute( network, ipxs.sipx_network, ipxs.sipx_node ); + if (retCode < 0 ) + { n_printf("IPX: Failure %d adding route <%08lx through %08lx:%02x%02x%02x%02x%02x%02x>\n", retCode, (unsigned long int)htonl(network), (unsigned long int)htonl(ipxs.sipx_network), ipxs.sipx_node[0],ipxs.sipx_node[1],ipxs.sipx_node[2], ipxs.sipx_node[3],ipxs.sipx_node[4],ipxs.sipx_node[5] ); - } else { - n_printf("IPX: Success adding route <%08lx through %08lx:%02x%02x%02x%02x%02x%02x>\n", + n_printf("IPX: Try manually add this route or use RIP daemon like ipxripd\n"); + } + else + { n_printf("IPX: Success adding route <%08lx through %08lx:%02x%02x%02x%02x%02x%02x>\n", (unsigned long int)htonl(network), (unsigned long int)htonl(ipxs.sipx_network), ipxs.sipx_node[0],ipxs.sipx_node[1],ipxs.sipx_node[2], ipxs.sipx_node[3],ipxs.sipx_node[4],ipxs.sipx_node[5] ); - } + } + } + close_proc_scan(); } else { printf("IPX: Error %d in GetLocalTarget main packet send/receive loop\n", retCode); } diff -ruN dosemu-1.1.3.orig/src/include/utilities.h dosemu-1.1.3/src/include/utilities.h --- dosemu-1.1.3.orig/src/include/utilities.h Tue Mar 19 00:58:13 2002 +++ dosemu-1.1.3/src/include/utilities.h Wed Aug 7 15:52:35 2002 @@ -26,6 +26,8 @@ char *get_proc_string_by_key(char *key); void advance_proc_bufferptr(void); void reset_proc_bufferptr(void); +int check_proc_ipx_route(unsigned long targetNet,unsigned long network, + unsigned char node[]); int get_proc_intvalue_by_key(char *key); int integer_sqrt(int x); int exists_dir(char *name); --Multipart_Wed__7_Aug_2002_16:43:26_+0400_081d5c38--