From: Stas Sergeev <stssppnn@yahoo.com>
To: linux-msdos@vger.kernel.org
Subject: Re: checking IPX route
Date: Thu, 08 Aug 2002 02:22:58 +0400 [thread overview]
Message-ID: <3D519DC2.2060707@yahoo.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
Hello.
> The attached patch is completely untested,
> please check if it works. I think I have
> completely preserved the logic of your patch,
> but who knows...
Yes, it is still completely untested but
contains one bug less than the previous one:)
Grigory, please see if this one works.
[-- Attachment #2: ipx_proc.diff --]
[-- Type: text/plain, Size: 3887 bytes --]
--- src/dosext/net/net/ipxglt.c Fri Aug 2 18:31:46 2002
+++ src/dosext/net/net/ipxglt.c Thu Aug 8 00:19:14 2002
@@ -33,6 +33,7 @@
#include "emu.h"
#include "dosemu_select.h"
+#include "utilities.h"
#define FALSE 0
#define TRUE 1
@@ -55,14 +56,16 @@
struct sockaddr_ipx *st = (struct sockaddr_ipx *)&rt.rt_dst;
struct sockaddr_ipx *sr = (struct sockaddr_ipx *)&rt.rt_gateway;
int sock;
- int i;
+ if (!can_do_root_stuff) {
+ error("IPX: Cannot add route, root privs required!\n");
+ return -2;
+ }
+
rt.rt_flags = RTF_GATEWAY;
st->sipx_network = targetNet;
sr->sipx_network = network;
- for( i=0; i<6; i++ ) {
- sr->sipx_node[i] = node[i];
- }
+ memcpy(sr->sipx_node, node, 6);
sr->sipx_family = st->sipx_family = AF_IPX;
enter_priv_on();
@@ -85,6 +88,33 @@
return(0);
}
+int CheckRouteExist(unsigned long targetNet, unsigned network,
+ unsigned char node[])
+{
+char buf_targ[9], buf_net[9], buf_node[13], proc_net[9], proc_node[13], *proc_str;
+
+ sprintf(buf_targ, "%08lX", (unsigned long)htonl(targetNet));
+ sprintf(buf_net, "%08lX", (unsigned long)htonl(network));
+ sprintf(buf_node, "%02X%02X%02X%02X%02X%02X", node[0], node[1],
+ node[2], node[3], node[4], node[5]);
+
+ open_proc_scan("/proc/net/ipx_route");
+ proc_str = get_proc_string_by_key(buf_targ);
+
+ if (!proc_str) {
+ close_proc_scan();
+ return 0;
+ }
+
+ sscanf(proc_str, "%s %s", proc_net, proc_node);
+ close_proc_scan();
+
+ if (strcmp(buf_net, proc_net) || strcmp(buf_node, proc_node))
+ return 0;
+
+ return 1;
+}
+
/* network must be passed in in network order (that is, high-low) */
/* returns 0 on success, less than 0 on failure */
int IPXGetLocalTarget( unsigned long network, int *hops, int *ticks )
@@ -220,20 +250,27 @@
*hops = htons(RipResponse.Hops);
*ticks = htons(RipResponse.Ticks);
- retCode = AddRoute( network, ipxs.sipx_network,
+ if (CheckRouteExist(network, ipxs.sipx_network, ipxs.sipx_node)) {
+ n_printf("IPX: Route <%08lx through %08lx:%02x%02x%02x%02x%02x%02x> already 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,
+ if( retCode < 0 ) {
+ error("IPX: Failure 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] );
- } else {
+ error("IPX: Try manually add this route with ipx_route command\nor 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] );
- }
+ }
+ }
} else {
printf("IPX: Error %d in GetLocalTarget main packet send/receive loop\n", retCode);
}
next reply other threads:[~2002-08-07 22:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-07 22:22 Stas Sergeev [this message]
2002-08-08 4:53 ` checking IPX route Grigory Batalov
-- strict thread matches above, loose matches on Subject: below --
2002-08-07 20:32 Stas Sergeev
2002-08-07 12:43 Grigory Batalov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D519DC2.2060707@yahoo.com \
--to=stssppnn@yahoo.com \
--cc=linux-msdos@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.