checking IPX route
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 .
Signature · 1 line
Grigory Batalov.
src/base/misc/utilities.c +29 -0
@@ -22,6 +22,7 @@#include "Linux/vt.h" #include <sys/ioctl.h> #include <errno.h> +#include <netinet/in.h> #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) {
src/dosext/net/net/ipxglt.c +21 -7
@@ -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); }
src/include/utilities.h +2 -0
@@ -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);