2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
14 * $Source: /cvs/cvsroot/d2x/arch/dos/ipx.c,v $
15 * $Revision: 1.1.1.1 $
17 * $Date: 2001-01-19 03:30:15 $
19 * Routines for IPX communications.
21 * $Log: not supported by cvs2svn $
22 * Revision 1.1.1.1 1999/06/14 21:58:22 donut
23 * Import of d1x 1.37 source.
25 * Revision 2.10 1995/03/29 17:27:55 john
26 * Added code to not duplicate broadcasts.
28 * Revision 2.9 1995/03/29 15:32:07 john
31 * Revision 2.8 1995/03/29 15:07:31 john
32 * Added network support.
34 * Revision 2.7 1995/03/29 11:22:27 john
35 * Added broadcasting over a net.
37 * Revision 2.6 1995/03/28 20:05:03 john
38 * Took away alternate server stuff.
40 * Revision 2.5 1995/03/23 19:14:29 john
41 * Added better MAX_USERS message.
43 * Revision 2.4 1995/03/23 19:00:02 john
44 * Added user list capabitly.
46 * Revision 2.3 1995/03/23 12:27:05 john
47 * Move IPX into bios lib.
49 * Revision 2.2 1995/03/22 19:08:15 john
50 * Added code to fix sending packets over router... now
51 * we just need to make broadcasts go over router!!
53 * Revision 2.1 1995/03/21 08:40:16 john
54 * Ifdef'd out the NETWORK code.
56 * Revision 2.0 1995/02/27 11:30:45 john
57 * New version 2.0, which has no anonymous unions, builds with
58 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
60 * Revision 1.31 1995/02/16 17:35:03 john
61 * Added code to allow dynamic socket changing.
63 * Revision 1.30 1995/02/01 21:03:45 john
66 * Revision 1.29 1995/01/22 14:31:05 john
69 * Revision 1.28 1995/01/22 14:29:26 john
70 * Added code to bypass broadcast messages.
72 * Revision 1.27 1995/01/03 13:46:16 john
73 * Added code that should make ipx work over different servers,
74 * but ifdef'd it out with SHAREWARE in ipx.c. I haven't tested
75 * this, and I hope it doesn't introduce net bugs.
77 * Revision 1.26 1994/12/14 11:54:37 rob
78 * Reduce # of ipx packets.
80 * Revision 1.25 1994/12/11 00:43:28 john
81 * Locked down DOS ipx buffers... probably not necessary, tho.
83 * Revision 1.24 1994/12/08 15:49:58 rob
84 * Bumped up the # of ipx packets.
86 * Revision 1.23 1994/12/04 15:23:54 rob
87 * Reduced packet # constants.
89 * Revision 1.22 1994/11/27 23:12:39 matt
90 * Made changes for new mprintf calling convention
92 * Revision 1.21 1994/11/19 15:15:19 mike
93 * remove unused code and data
95 * Revision 1.20 1994/11/10 11:06:07 rob
96 * Raised number of ipx packets to 64 and buffers to 128 (for 8-way games)
97 * Removed (commented out) all the spx support stuff.
99 * Revision 1.19 1994/11/07 17:50:12 rob
100 * Bumped up max_packets and ipx_num_packets to double their previous
103 * Revision 1.18 1994/11/07 15:39:01 rob
104 * Removed temporary hacked ipx_send_object function.
105 * Replaced with a more general thing.
107 * Revision 1.17 1994/11/05 16:08:40 rob
108 * Made a change necessary for object syncing on rejoin.
110 * Revision 1.16 1994/11/01 15:57:12 rob
111 * Added support for SPX sockets for critical messages.
113 * Revision 1.15 1994/10/31 19:21:01 rob
114 * Added a routine for sending objects via ipx. Its a hack and shoukld
115 * be replaced by something more general time permitting.
117 * Revision 1.14 1994/10/20 14:57:42 john
120 * Revision 1.13 1994/10/20 11:22:45 john
121 * Tweaked the number of waiting packets. Added code to print
122 * total packets missed, and to limit the packet send rate to
123 * 10 packets per second unless firing.
125 * Revision 1.12 1994/10/03 20:50:11 john
126 * Started adding sound pause functions.
128 * Revision 1.11 1994/09/15 08:54:24 mike
129 * comment out a mprintf.
131 * Revision 1.10 1994/09/12 19:38:20 john
132 * Made some stuff that prints to the DOS screen go to the
133 * mono instead, since it really is debugging info.
135 * Revision 1.9 1994/09/07 13:32:03 john
136 * Made ipx_close explicitly close the socket we were using,
137 * because it seems that VLM's don't automatically close them
138 * like the older NETX stuff did (Going from Novell 3.11 driver
141 * Revision 1.8 1994/09/06 19:29:20 john
142 * Added trial version of rejoin function.
144 * Revision 1.7 1994/08/09 19:31:50 john
145 * Networking changes.
147 * Revision 1.6 1994/08/05 16:11:41 john
148 * Psuedo working version of networking.
150 * Revision 1.5 1994/08/04 19:17:21 john
151 * Inbetween version of network stuff.
153 * Revision 1.4 1994/07/29 16:08:57 john
154 * *** empty log message ***
156 * Revision 1.3 1994/07/25 12:33:31 john
157 * Network "pinging" in.
159 * Revision 1.2 1994/07/20 15:58:28 john
160 * First installment of ipx stuff.
162 * Revision 1.1 1994/07/19 15:42:00 john
169 static char rcsid[] = "$Id: ipx.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $";
173 #define _BORLAND_DOS_REGS 1
193 typedef unsigned char BYTE;
194 typedef unsigned short WORD;
195 typedef unsigned long DWORD;
197 typedef struct local_address {
199 } __pack__ local_address;
201 typedef struct net_address {
203 local_address node_id;
205 } __pack__ net_address;
207 typedef struct ipx_header {
210 BYTE transport_control;
212 net_address destination;
214 } __pack__ ipx_header;
216 typedef struct ecb_header {
220 BYTE completion_code;
222 BYTE ipx_reserved[14];
224 local_address immediate_address;
226 WORD fragment_pointer[2];
228 } __pack__ ecb_header;
230 typedef struct packet_data {
232 byte data[IPX_MAX_DATA_SIZE];
233 } __pack__ packet_data;
235 typedef struct ipx_packet {
239 } __pack__ ipx_packet;
241 typedef struct user_address {
245 } __pack__ user_address;
248 int Ipx_num_users = 0;
249 user_address Ipx_users[MAX_USERS];
251 #define MAX_NETWORKS 64
252 int Ipx_num_networks = 0;
253 uint Ipx_networks[MAX_NETWORKS];
255 int ipx_packetnum = 0;
257 #define MAX_PACKETS 64
259 static packet_data packet_buffers[MAX_PACKETS];
260 static short packet_free_list[MAX_PACKETS];
261 static int num_packets = 0;
262 static int largest_packet_index = 0;
263 static short packet_size[MAX_PACKETS];
266 ubyte ipx_installed=0;
267 WORD ipx_vector_segment;
268 WORD ipx_vector_offset;
269 ubyte ipx_socket_life = 0; // 0=closed at prog termination, 0xff=closed when requested.
270 DWORD ipx_network = 0;
271 local_address ipx_my_node;
272 WORD ipx_num_packets=32; // 32 Ipx packets
273 ipx_packet * packets;
275 ushort ipx_packets_selector;
277 ecb_header * last_ecb=NULL;
280 void got_new_packet( ecb_header * ecb );
281 void ipx_listen_for_packet(ecb_header * ecb );
283 void free_packet( int id )
285 packet_buffers[id].packetnum = -1;
286 packet_free_list[ --num_packets ] = id;
287 if (largest_packet_index==id)
288 while ((--largest_packet_index>0) && (packet_buffers[largest_packet_index].packetnum == -1 ));
291 int ipx_get_packet_data( ubyte * data )
293 int i, n, best, best_id, size;
295 for (i=1; i<ipx_num_packets; i++ ) {
296 if ( !packets[i].ecb.in_use ) {
297 got_new_packet( &packets[i].ecb );
298 packets[i].ecb.in_use = 0;
299 ipx_listen_for_packet(&packets[i].ecb);
307 for (i=0; i<=largest_packet_index; i++ ) {
308 if ( packet_buffers[i].packetnum > -1 ) {
310 if ( best == -1 || (packet_buffers[i].packetnum<best) ) {
311 best = packet_buffers[i].packetnum;
317 //mprintf( (0, "Best id = %d, pn = %d, last_ecb = %x, len=%x, ne = %d\n", best_id, best, last_ecb, lastlen, neterrors ));
318 //mprintf( (1, "<%d> ", neterrors ));
320 if ( best_id < 0 ) return 0;
322 size = packet_size[best_id];
323 memcpy( data, packet_buffers[best_id].data, size );
324 free_packet(best_id);
330 unsigned int swap_short( unsigned int short )
331 #pragma aux swap_short parm [eax] = "xchg al,ah";
333 static inline unsigned int swap_short( unsigned int sshort ) {
335 asm("xchg %%ah,%%al" : "=a" (__retval) : "a" (sshort));
340 void got_new_packet( ecb_header * ecb )
344 unsigned short datasize;
348 p = (ipx_packet *)ecb;
350 if ( p->ecb.in_use ) { neterrors++; return; }
351 if ( p->ecb.completion_code ) { neterrors++; return; }
353 // Error( "Recieve error %d for completion code", p->ecb.completion_code );
355 if ( memcmp( &p->ipx.source.node_id, &ipx_my_node, 6 ) ) {
356 datasize=swap_short(p->ipx.length);
358 datasize -= sizeof(ipx_header);
359 // Find slot to put packet in...
360 if ( datasize > 0 && datasize <= sizeof(packet_data) ) {
361 if ( num_packets >= MAX_PACKETS ) {
362 //printf( 1, "IPX: Packet buffer overrun!!!\n" );
366 id = packet_free_list[ num_packets++ ];
367 if (id > largest_packet_index ) largest_packet_index = id;
368 packet_size[id] = datasize-sizeof(int);
369 packet_buffers[id].packetnum = p->pd.packetnum;
370 if ( packet_buffers[id].packetnum < 0 ) { neterrors++; return; }
371 memcpy( packet_buffers[id].data, p->pd.data, packet_size[id] );
378 //ipx_listen_for_packet(&p->ecb);
381 ubyte * ipx_get_my_local_address()
383 return ipx_my_node.address;
386 ubyte * ipx_get_my_server_address()
388 return (ubyte *)&ipx_network;
391 void ipx_listen_for_packet(ecb_header * ecb )
393 dpmi_real_regs rregs;
395 memset(&rregs,0,sizeof(dpmi_real_regs));
396 rregs.ebx = 4; // Listen For Packet function
397 rregs.esi = DPMI_real_offset(ecb);
398 rregs.es = DPMI_real_segment(ecb);
399 dpmi_real_int386x( 0x7A, &rregs );
402 void ipx_cancel_listen_for_packet(ecb_header * ecb )
404 dpmi_real_regs rregs;
405 memset(&rregs,0,sizeof(dpmi_real_regs));
406 rregs.ebx = 6; // IPX Cancel event
407 rregs.esi = DPMI_real_offset(ecb);
408 rregs.es = DPMI_real_segment(ecb);
409 dpmi_real_int386x( 0x7A, &rregs );
413 void ipx_send_packet(ecb_header * ecb )
415 dpmi_real_regs rregs;
416 memset(&rregs,0,sizeof(dpmi_real_regs));
417 rregs.ebx = 3; // Send Packet function
418 rregs.esi = DPMI_real_offset(ecb);
419 rregs.es = DPMI_real_segment(ecb);
420 dpmi_real_int386x( 0x7A, &rregs );
426 ubyte local_target[6];
427 } __pack__ net_xlat_info;
429 void ipx_get_local_target( ubyte * server, ubyte * node, ubyte * local_target )
431 net_xlat_info * info;
432 dpmi_real_regs rregs;
434 // Get dos memory for call...
435 info = (net_xlat_info *)dpmi_get_temp_low_buffer( sizeof(net_xlat_info) );
436 assert( info != NULL );
437 memcpy( info->network, server, 4 );
438 memcpy( info->node, node, 6 );
440 memset(&rregs,0,sizeof(dpmi_real_regs));
442 rregs.ebx = 2; // Get Local Target
443 rregs.es = DPMI_real_segment(info);
444 rregs.esi = DPMI_real_offset(info->network);
445 rregs.edi = DPMI_real_offset(info->local_target);
447 dpmi_real_int386x( 0x7A, &rregs );
449 // Save the local target...
450 memcpy( local_target, info->local_target, 6 );
455 dpmi_real_regs rregs;
456 if ( ipx_installed ) {
457 // When using VLM's instead of NETX, the sockets don't
458 // seem to automatically get closed, so we must explicitly
459 // close them at program termination.
461 memset(&rregs,0,sizeof(dpmi_real_regs));
462 rregs.edx = ipx_socket;
463 rregs.ebx = 1; // Close socket
464 dpmi_real_int386x( 0x7A, &rregs );
469 //---------------------------------------------------------------
470 // Initializes all IPX internals.
471 // If socket_number==0, then opens next available socket.
472 // Returns: 0 if successful.
473 // -1 if socket already open.
474 // -2 if socket table full.
475 // -3 if IPX not installed.
476 // -4 if couldn't allocate low dos memory
477 // -5 if error with getting internetwork address
479 int ipx_init( int socket_number, int show_address )
481 dpmi_real_regs rregs;
482 ubyte *ipx_real_buffer;
489 // init packet buffers.
490 for (i=0; i<MAX_PACKETS; i++ ) {
491 packet_buffers[i].packetnum = -1;
492 packet_free_list[i] = i;
495 largest_packet_index = 0;
497 // Get the IPX vector
498 memset(&rregs,0,sizeof(dpmi_real_regs));
499 rregs.eax=0x00007a00;
500 dpmi_real_int386x( 0x2f, &rregs );
502 if ( (rregs.eax & 0xFF) != 0xFF ) {
505 ipx_vector_offset = rregs.edi & 0xFFFF;
506 ipx_vector_segment = rregs.es;
507 //printf( "IPX entry point at %.4x:%.4x\n", ipx_vector_segment, ipx_vector_offset );
509 // Open a socket for IPX
511 memset(&rregs,0,sizeof(dpmi_real_regs));
512 swab( (char *)&socket_number,(char *)&ipx_socket, 2 );
513 rregs.edx = ipx_socket;
514 rregs.eax = ipx_socket_life;
515 rregs.ebx = 0; // Open socket
516 dpmi_real_int386x( 0x7A, &rregs );
518 ipx_socket = rregs.edx & 0xFFFF;
520 if ( rregs.eax & 0xFF ) {
521 //mprintf( (1, "IPX error opening channel %d\n", socket_number-IPX_DEFAULT_SOCKET ));
527 // Find our internetwork address
528 ipx_real_buffer = dpmi_get_temp_low_buffer( 1024 ); // 1k block
529 if ( ipx_real_buffer == NULL ) {
530 //printf( "Error allocation realmode memory\n" );
534 memset(&rregs,0,sizeof(dpmi_real_regs));
535 rregs.ebx = 9; // Get internetwork address
536 rregs.esi = DPMI_real_offset(ipx_real_buffer);
537 rregs.es = DPMI_real_segment(ipx_real_buffer);
538 dpmi_real_int386x( 0x7A, &rregs );
540 if ( rregs.eax & 0xFF ) {
541 //printf( "Error getting internetwork address!\n" );
545 memcpy( &ipx_network, ipx_real_buffer, 4 );
546 memcpy( &ipx_my_node, &ipx_real_buffer[4], 6 );
548 Ipx_num_networks = 0;
549 memcpy( &Ipx_networks[Ipx_num_networks++], &ipx_network, 4 );
551 if ( show_address ) {
552 printf( "My IPX addresss is " );
553 printf( "%02X%02X%02X%02X/", ipx_real_buffer[0],ipx_real_buffer[1],ipx_real_buffer[2],ipx_real_buffer[3] );
554 printf( "%02X%02X%02X%02X%02X%02X\n", ipx_real_buffer[4],ipx_real_buffer[5],ipx_real_buffer[6],ipx_real_buffer[7],ipx_real_buffer[8],ipx_real_buffer[9] );
558 packets = dpmi_real_malloc( sizeof(ipx_packet)*ipx_num_packets, &ipx_packets_selector );
559 if ( packets == NULL ) {
560 //printf( "Couldn't allocate real memory for %d packets\n", ipx_num_packets );
563 #if 0 /* adb: not needed, fails with cwsdpmi */
564 if (!dpmi_lock_region( packets, sizeof(ipx_packet)*ipx_num_packets )) {
565 //printf( "Couldn't lock real memory for %d packets\n", ipx_num_packets );
569 memset( packets, 0, sizeof(ipx_packet)*ipx_num_packets );
571 for (i=1; i<ipx_num_packets; i++ ) {
572 packets[i].ecb.in_use = 0x1d;
573 //packets[i].ecb.in_use = 0;
574 packets[i].ecb.socket_id = ipx_socket;
575 packets[i].ecb.fragment_count = 1;
576 packets[i].ecb.fragment_pointer[0] = DPMI_real_offset(&packets[i].ipx);
577 packets[i].ecb.fragment_pointer[1] = DPMI_real_segment(&packets[i].ipx);
578 packets[i].ecb.fragment_size = sizeof(ipx_packet)-sizeof(ecb_header); //-sizeof(ecb_header);
580 ipx_listen_for_packet(&packets[i].ecb);
583 packets[0].ecb.socket_id = ipx_socket;
584 packets[0].ecb.fragment_count = 1;
585 packets[0].ecb.fragment_pointer[0] = DPMI_real_offset(&packets[0].ipx);
586 packets[0].ecb.fragment_pointer[1] = DPMI_real_segment(&packets[0].ipx);
587 packets[0].ipx.packet_type = 4; // IPX packet
588 packets[0].ipx.destination.socket_id = ipx_socket;
589 // memcpy( packets[0].ipx.destination.network_id, &ipx_network, 4 );
590 memset( packets[0].ipx.destination.network_id, 0, 4 );
595 void ipx_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address )
597 assert(ipx_installed);
599 if ( datasize >= IPX_MAX_DATA_SIZE ) {
600 printf( "Data too big\n" );
601 //added/replaced on 11/8/98 by Victor Rachels to stop crappage
604 //end this section replacement - VR
607 // Make sure no one is already sending something
608 while( packets[0].ecb.in_use )
612 if (packets[0].ecb.completion_code) {
613 // printf( "Send error %d for completion code\n", packets[0].ecb.completion_code );
614 //added/replaced on 11/8/98 by Victor Rachels to stop crappage
617 //end this section replacement - VR
621 // Fill in destination address
622 if ( memcmp( network, &ipx_network, 4 ) )
623 memcpy( packets[0].ipx.destination.network_id, network, 4 );
625 memset( packets[0].ipx.destination.network_id, 0, 4 );
626 memcpy( packets[0].ipx.destination.node_id.address, address, 6 );
627 memcpy( packets[0].ecb.immediate_address.address, immediate_address, 6 );
628 packets[0].pd.packetnum = ipx_packetnum++;
630 // Fill in data to send
631 packets[0].ecb.fragment_size = sizeof(ipx_header) + sizeof(int) + datasize;
633 assert( datasize > 1 );
634 assert( packets[0].ecb.fragment_size <= 576 );
636 memcpy( packets[0].pd.data, data, datasize );
639 ipx_send_packet( &packets[0].ecb );
643 void ipx_send_broadcast_packet_data( ubyte * data, int datasize )
646 ubyte broadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
647 ubyte local_address[6];
649 // Set to all networks besides mine
650 for (i=0; i<Ipx_num_networks; i++ ) {
651 if ( memcmp( &Ipx_networks[i], &ipx_network, 4 ) ) {
652 ipx_get_local_target( (ubyte *)&Ipx_networks[i], broadcast, local_address );
653 ipx_send_packet_data( data, datasize, (ubyte *)&Ipx_networks[i], broadcast, local_address );
655 ipx_send_packet_data( data, datasize, (ubyte *)&Ipx_networks[i], broadcast, broadcast );
659 //OLDipx_send_packet_data( data, datasize, (ubyte *)&ipx_network, broadcast, broadcast );
661 // Send directly to all users not on my network or in the network list.
662 for (i=0; i<Ipx_num_users; i++ ) {
663 if ( memcmp( Ipx_users[i].network, &ipx_network, 4 ) ) {
664 for (j=0; j<Ipx_num_networks; j++ ) {
665 if (!memcmp( Ipx_users[i].network, &Ipx_networks[j], 4 ))
668 ipx_send_packet_data( data, datasize, Ipx_users[i].network, Ipx_users[i].node, Ipx_users[i].address );
675 // Sends a non-localized packet... needs 4 byte server, 6 byte address
676 void ipx_send_internetwork_packet_data( ubyte * data, int datasize, ubyte * server, ubyte *address )
678 ubyte local_address[6];
680 if ( (*(uint *)server) != 0 ) {
681 ipx_get_local_target( server, address, local_address );
682 ipx_send_packet_data( data, datasize, server, address, local_address );
684 // Old method, no server info.
685 ipx_send_packet_data( data, datasize, server, address, address );
689 int ipx_change_default_socket( ushort socket_number )
693 dpmi_real_regs rregs;
695 if ( !ipx_installed ) return -3;
698 memset(&rregs,0,sizeof(dpmi_real_regs));
699 swab( (char *)&socket_number,(char *)&new_ipx_socket, 2 );
700 rregs.edx = new_ipx_socket;
701 rregs.eax = ipx_socket_life;
702 rregs.ebx = 0; // Open socket
703 dpmi_real_int386x( 0x7A, &rregs );
705 new_ipx_socket = rregs.edx & 0xFFFF;
707 if ( rregs.eax & 0xFF ) {
708 //printf( (1, "IPX error opening channel %d\n", socket_number-IPX_DEFAULT_SOCKET ));
712 for (i=1; i<ipx_num_packets; i++ ) {
713 ipx_cancel_listen_for_packet(&packets[i].ecb);
716 // Close existing socket...
717 memset(&rregs,0,sizeof(dpmi_real_regs));
718 rregs.edx = ipx_socket;
719 rregs.ebx = 1; // Close socket
720 dpmi_real_int386x( 0x7A, &rregs );
722 ipx_socket = new_ipx_socket;
724 // Repost all listen requests on the new socket...
725 for (i=1; i<ipx_num_packets; i++ ) {
726 packets[i].ecb.in_use = 0;
727 packets[i].ecb.socket_id = ipx_socket;
728 ipx_listen_for_packet(&packets[i].ecb);
731 packets[0].ecb.socket_id = ipx_socket;
732 packets[0].ipx.destination.socket_id = ipx_socket;
735 // init packet buffers.
736 for (i=0; i<MAX_PACKETS; i++ ) {
737 packet_buffers[i].packetnum = -1;
738 packet_free_list[i] = i;
741 largest_packet_index = 0;
746 void ipx_read_user_file(char * filename)
750 char temp_line[132], *p1;
753 if (!filename) return;
757 fp = fopen( filename, "rt" );
760 printf( "Broadcast Users:\n" );
762 while (fgets(temp_line, 132, fp)) {
764 p1 = strchr(temp_line,'\n'); if (p1) *p1 = '\0';
765 p1 = strchr(temp_line,';'); if (p1) *p1 = '\0';
766 n = sscanf( temp_line, "%2x%2x%2x%2x/%2x%2x%2x%2x%2x%2x",(unsigned int *)&tmp.network[0],(unsigned int *) &tmp.network[1],(unsigned int *) &tmp.network[2],(unsigned int *) &tmp.network[3],(unsigned int *) &tmp.node[0],(unsigned int *) &tmp.node[1],(unsigned int *) &tmp.node[2],(unsigned int *)&tmp.node[3],(unsigned int *) &tmp.node[4],(unsigned int *) &tmp.node[5] );
767 if ( n != 10 ) continue;
768 if ( Ipx_num_users < MAX_USERS ) {
769 ubyte * ipx_real_buffer = (ubyte *)&tmp;
770 ipx_get_local_target( tmp.network, tmp.node, tmp.address );
771 Ipx_users[Ipx_num_users++] = tmp;
772 printf( "%02X%02X%02X%02X/", ipx_real_buffer[0],ipx_real_buffer[1],ipx_real_buffer[2],ipx_real_buffer[3] );
773 printf( "%02X%02X%02X%02X%02X%02X\n", ipx_real_buffer[4],ipx_real_buffer[5],ipx_real_buffer[6],ipx_real_buffer[7],ipx_real_buffer[8],ipx_real_buffer[9] );
775 printf( "Too many addresses in %s! (Limit of %d)\n", filename, MAX_USERS );
784 void ipx_read_network_file(char * filename)
788 char temp_line[132], *p1;
791 if (!filename) return;
793 fp = fopen( filename, "rt" );
796 printf( "Using Networks:\n" );
797 for (i=0; i<Ipx_num_networks; i++ ) {
798 ubyte * n1 = (ubyte *)&Ipx_networks[i];
799 printf("* %02x%02x%02x%02x\n", n1[0], n1[1], n1[2], n1[3] );
802 while (fgets(temp_line, 132, fp)) {
804 p1 = strchr(temp_line,'\n'); if (p1) *p1 = '\0';
805 p1 = strchr(temp_line,';'); if (p1) *p1 = '\0';
806 n = sscanf( temp_line, "%2x%2x%2x%2x",(unsigned int *) &tmp.network[0],(unsigned int *) &tmp.network[1],(unsigned int *) &tmp.network[2],(unsigned int *) &tmp.network[3] );
807 if ( n != 4 ) continue;
808 if ( Ipx_num_networks < MAX_NETWORKS ) {
810 for (j=0; j<Ipx_num_networks; j++ )
811 if ( !memcmp( &Ipx_networks[j], tmp.network, 4 ) )
813 if ( j >= Ipx_num_networks ) {
814 memcpy( &Ipx_networks[Ipx_num_networks++], tmp.network, 4 );
815 printf(" %02x%02x%02x%02x\n", tmp.network[0], tmp.network[1], tmp.network[2], tmp.network[3] );
818 printf( "Too many networks in %s! (Limit of %d)\n", filename, MAX_NETWORKS );
827 //---typedef struct rip_entry {
833 //---typedef struct rip_packet {
834 //--- ushort operation; //1=request, 2=response
835 //--- rip_entry rip[50];
839 //---void ipx_find_all_servers()
842 //--- rip_packet * rp;
843 //--- assert(ipx_installed);
845 //--- ipx_change_default_socket( 0x0453 );
846 //--- // ipx_change_default_socket( 0x5304 );
848 //--- // Make sure no one is already sending something
849 //--- while( packets[0].ecb.in_use )
853 //--- if (packets[0].ecb.completion_code) {
854 //--- printf( "AAAA:Send error %d for completion code\n", packets[0].ecb.completion_code );
858 //--- rp = (rip_packet *)&packets[0].pd;
860 //--- // Fill in destination address
862 //--- char mzero1[] = {0,0,0,1};
863 //--- char mzero[] = {0,0,0,0,0,1};
864 //--- char immediate[6];
865 //--- //memcpy( packets[0].ipx.destination.network_id, &ipx_network, 4 );
866 //--- //memcpy( packets[0].ipx.destination.node_id.address, ipx_my_node.address, 6 );
868 //--- memcpy( packets[0].ipx.destination.network_id, mzero1, 4 );
869 //--- memcpy( packets[0].ipx.destination.node_id.address, mzero, 6 );
871 //--- memcpy( packets[0].ipx.destination.socket_id, &ipx_socket, 2 );
872 //--- memcpy( packets[0].ipx.source.network_id, &ipx_network, 4 );
873 //--- memcpy( packets[0].ipx.source.node_id.address, ipx_my_node.address, 6 );
874 //--- memcpy( packets[0].ipx.source.socket_id, &ipx_socket, 2 );
875 //--- //memcpy( packets[0].ecb.immediate_address.address, ipx_my_node.address, 6 );
876 //--- //mzero1[3] = 1;
877 //--- //memcpy( packets[0].ipx.destination.network_id, mzero1, 4 );
878 //--- //mzero[5] = 1;
879 //--- //memcpy( packets[0].ipx.destination.node_id.address, mzero, 6 );
880 //--- //ipx_get_local_target( mzero1, mzero, immediate );
881 //--- //memcpy( packets[0].ecb.immediate_address.address, mzero, 6 );
882 //--- //memcpy( packets[0].ecb.immediate_address.address, immediate, 6 );
883 //--- //mzero[5] = 0;
886 //--- packets[0].ipx.packet_type = 1; // RIP packet
888 //--- // Fill in data to send
889 //--- packets[0].ecb.fragment_size = sizeof(ipx_header) + sizeof(rip_packet);
890 //--- assert( packets[0].ecb.fragment_size <= 576 );
892 //--- rp->operation = 0; // Request
893 //--- for (i=0;i<50; i++) {
894 //--- rp->rip[i].network = 0xFFFFFFFF;
895 //--- rp->rip[i].nhops = 0;
896 //--- rp->rip[i].nticks = 0;
900 //--- ipx_send_packet( &packets[0].ecb );
902 //--- for (i=0;i<50; i++) {
903 //--- if ( rp->rip[i].network != 0xFFFFFFFF )
904 //--- printf( "Network = %8x, Hops=%d, Ticks=%d\n", rp->rip[i].network, rp->rip[i].nhops, rp->rip[i].nticks );